about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-04-10 07:04:41 +0000
committerEric Wong <normalperson@yhbt.net>2011-04-10 07:04:41 +0000
commit983e8ff915118d00b683109df0834733b485086d (patch)
tree499e228b999c1e44b1142f0fa5ba38c62b7c9453
parent01949865e2715b487e098dbc60ba3ae7a01a3b54 (diff)
downloadkgio-983e8ff915118d00b683109df0834733b485086d.tar.gz
Another thread may have killed the descriptor.
-rw-r--r--ext/kgio/read_write.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/kgio/read_write.c b/ext/kgio/read_write.c
index f43942e..26ef779 100644
--- a/ext/kgio/read_write.c
+++ b/ext/kgio/read_write.c
@@ -76,8 +76,10 @@ static void prepare_read(struct io_args *a, int argc, VALUE *argv, VALUE io)
 static int read_check(struct io_args *a, long n, const char *msg, int io_wait)
 {
         if (n == -1) {
-                if (errno == EINTR)
+                if (errno == EINTR) {
+                        a->fd = my_fileno(a->io);
                         return -1;
+                }
                 rb_str_set_len(a->buf, 0);
                 if (errno == EAGAIN) {
                         if (io_wait) {
@@ -307,8 +309,10 @@ static int write_check(struct io_args *a, long n, const char *msg, int io_wait)
 done:
                 a->buf = Qnil;
         } else if (n == -1) {
-                if (errno == EINTR)
+                if (errno == EINTR) {
+                        a->fd = my_fileno(a->io);
                         return -1;
+                }
                 if (errno == EAGAIN) {
                         long written = RSTRING_LEN(a->buf) - a->len;