Project

General

Profile

Bug #4463 ยป 0001-release-GVL-for-fcntl-for-operations-that-may-block.patch

normalperson (Eric Wong), 03/03/2011 06:58 PM

View differences:

io.c
}
#if defined(HAVE_FCNTL) && defined(F_SETLKW)
/* release GVL for blocking POSIX locks */
struct fcntl_arg {
int fd;
int cmd;
long narg;
};
static VALUE nogvl_fcntl(void *ptr)
{
struct fcntl_arg *arg = ptr;
return (VALUE)fcntl(arg->fd, arg->cmd, arg->narg);
}
static int maygvl_fcntl(int fd, int cmd, long narg)
{
struct fcntl_arg arg;
if (cmd != F_SETLKW)
return fcntl(fd, cmd, narg);
arg.fd = fd;
arg.cmd = cmd;
arg.narg = narg;
return (int)rb_thread_blocking_region(nogvl_fcntl, &arg, RUBY_UBF_IO, 0);
}
#else /* no (F_SETLKW) or POSIX locks */
# define maygvl_fcntl fcntl
#endif
static int
io_cntl(int fd, unsigned long cmd, long narg, int io_p)
{
......
# if defined(__CYGWIN__)
retval = io_p?ioctl(fd, cmd, (void*)narg):fcntl(fd, cmd, narg);
# else
retval = io_p?ioctl(fd, cmd, narg):fcntl(fd, (int)cmd, narg);
retval = io_p?ioctl(fd, cmd, narg):maygvl_fcntl(fd, (int)cmd, narg);
# endif
# if defined(F_DUPFD)
if (!io_p && retval != -1 && cmd == F_DUPFD) {
-
    (1-1/1)