summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-04-11 12:52:22 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-04-11 12:52:22 +0000
commit0f771e33e2c3be4bc6316d6f4a930ba67ed0a9a3 (patch)
tree7433938660808e97275949e9f142c579901603ed /io.c
parent616f70fcf6c81ca70b46951ddf605008a2848a92 (diff)
* io.c: revert r31230.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c47
1 files changed, 4 insertions, 43 deletions
diff --git a/io.c b/io.c
index 7ce7148627..46845eb58b 100644
--- a/io.c
+++ b/io.c
@@ -3490,45 +3490,6 @@ finish_writeconv_sync(VALUE arg)
return finish_writeconv(p->fptr, p->noalloc);
}
-static VALUE
-nogvl_close(void *ptr)
-{
- int *fd = ptr;
-
- return (VALUE)close(*fd);
-}
-
-static int
-maygvl_close(int fd, int keepgvl)
-{
- if (keepgvl)
- return close(fd);
-
- /*
- * close() may block for certain file types (NFS, SO_LINGER sockets,
- * inotify), so let other threads run.
- */
- return (int)rb_thread_blocking_region(nogvl_close, &fd, RUBY_UBF_IO, 0);
-}
-
-static VALUE
-nogvl_fclose(void *ptr)
-{
- FILE *file = ptr;
-
- return (VALUE)fclose(file);
-}
-
-static int
-maygvl_fclose(FILE *file, int keepgvl)
-{
- if (keepgvl)
- return fclose(file);
-
- return (int)rb_thread_blocking_region(nogvl_fclose, file, RUBY_UBF_IO, 0);
-}
-
-
static void
fptr_finalize(rb_io_t *fptr, int noraise)
{
@@ -3560,15 +3521,15 @@ fptr_finalize(rb_io_t *fptr, int noraise)
if (fptr->stdio_file) {
/* fptr->stdio_file is deallocated anyway
* even if fclose failed. */
- if ((maygvl_fclose(fptr->stdio_file, noraise) < 0) && NIL_P(err))
+ if (fclose(fptr->stdio_file) < 0 && NIL_P(err))
err = noraise ? Qtrue : INT2NUM(errno);
}
else if (0 <= fptr->fd) {
/* fptr->fd may be closed even if close fails.
* POSIX doesn't specify it.
* We assumes it is closed. */
- if ((maygvl_close(fptr->fd, noraise) < 0) && NIL_P(err))
- err = noraise ? Qtrue : INT2NUM(errno);
+ if (close(fptr->fd) < 0 && NIL_P(err))
+ err = noraise ? Qtrue : INT2NUM(errno);
}
skip_fd_close:
fptr->fd = -1;
@@ -5824,7 +5785,7 @@ io_reopen(VALUE io, VALUE nfile)
rb_sys_fail_path(orig->pathv);
}
else {
- maygvl_fclose(fptr->stdio_file, 0);
+ fclose(fptr->stdio_file);
fptr->stdio_file = 0;
fptr->fd = -1;
if (dup2(fd2, fd) < 0)