From 42c802126215101feed36135ba8f9601895ec03a Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 12 Feb 1999 11:17:06 +0000 Subject: 990212 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index ac4771eb81..3223c893d8 100644 --- a/io.c +++ b/io.c @@ -111,7 +111,10 @@ extern int ReadDataPending(); # define READ_CHECK(fp) 0 #else # define READ_CHECK(fp) do {\ - if (!READ_DATA_PENDING(fp)) rb_thread_wait_fd(fileno(fp));\ + if (!READ_DATA_PENDING(fp)) {\ + rb_thread_wait_fd(fileno(fp));\ + rb_io_check_closed(fptr);\ + }\ } while(0) #endif @@ -841,8 +844,14 @@ static void rb_io_fptr_close(fptr) OpenFile *fptr; { + int fd; + if (fptr->f == NULL && fptr->f2 == NULL) return; +#ifdef USE_THREAD + rb_thread_fd_close(fileno(fptr->f)); +#endif + if (fptr->finalize) { (*fptr->finalize)(fptr); } @@ -954,7 +963,9 @@ rb_io_syswrite(io, str) f = GetWriteFile(fptr); #ifdef USE_THREAD - rb_thread_fd_writable(fileno(f)); + if (!rb_thread_fd_writable(fileno(f))) { + rb_io_check_closed(fptr); + } #endif n = write(fileno(f), RSTRING(str)->ptr, RSTRING(str)->len); @@ -1588,6 +1599,9 @@ rb_io_reopen(io, nfile) else if (orig->mode & FMODE_WRITABLE) { fflush(orig->f); } +#ifdef USE_THREAD + rb_thread_fd_close(fileno(fptr->f)); +#endif /* copy OpenFile structure */ fptr->mode = orig->mode; -- cgit v1.2.3