Bug #4527 ยป 0001-IO-close-releases-GVL-if-possible.patch
| io.c | ||
|---|---|---|
|
return finish_writeconv(p->fptr, p->noalloc);
|
||
|
}
|
||
|
static VALUE
|
||
|
nogvl_close(void *ptr)
|
||
|
{
|
||
|
int *fd = (int *)ptr;
|
||
|
return (VALUE)close(*fd);
|
||
|
}
|
||
|
static int
|
||
|
maygvl_close(int fd, int keepgvl)
|
||
|
{
|
||
|
if (keepgvl)
|
||
|
return close(fd);
|
||
|
return (int)rb_thread_blocking_region(nogvl_close, &fd, RUBY_UBF_IO, 0);
|
||
|
}
|
||
|
static void
|
||
|
fptr_finalize(rb_io_t *fptr, int noraise)
|
||
|
{
|
||
| ... | ... | |
|
/* fptr->fd may be closed even if close fails.
|
||
|
* POSIX doesn't specify it.
|
||
|
* We assumes it is closed. */
|
||
|
if (close(fptr->fd) < 0 && NIL_P(err))
|
||
|
if (maygvl_close(fptr->fd, noraise) < 0 && NIL_P(err))
|
||
|
err = noraise ? Qtrue : INT2NUM(errno);
|
||
|
}
|
||
|
skip_fd_close:
|
||
| ... | ... | |
|
#endif
|
||
|
}
|
||
|
else {
|
||
|
if (close(fptr->fd) < 0)
|
||
|
if (maygvl_close(fptr->fd, 0) < 0)
|
||
|
rb_sys_fail_path(fptr->pathv);
|
||
|
fptr->fd = -1;
|
||
|
fptr->fd = rb_sysopen(fptr->pathv, oflags, 0666);
|
||