summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-12 11:17:06 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-12 11:17:06 +0000
commit42c802126215101feed36135ba8f9601895ec03a (patch)
treefde428b1886469b75e73222107e2ee5fdc798ef3 /io.c
parent997ff23758884944f28a089eaa50ac7eb1c026c6 (diff)
990212
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c18
1 files changed, 16 insertions, 2 deletions
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;