summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-09 13:27:04 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-09 13:27:04 +0000
commitb4f90b236c56601a1d112af7c116fc9ef80703d6 (patch)
treed74d3b172fec0bfde86b063b2ee3ed02544ac8e1 /io.c
parentf2bd994409bb6a8fb96eeadcbc12cbc3e30fb80e (diff)
* io.c (READ_CHECK): do not select fd before reading, that had made
TCPServer#gets stuck. [ruby-dev:40317] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/io.c b/io.c
index 8926c315f1..da3fc7bb7b 100644
--- a/io.c
+++ b/io.c
@@ -175,9 +175,15 @@ static int max_file_descriptor = NOFILE;
#define READ_DATA_PENDING_PTR(fptr) ((fptr)->rbuf+(fptr)->rbuf_off)
#define READ_DATA_BUFFERED(fptr) READ_DATA_PENDING(fptr)
+#if defined(_WIN32)
+#define WAIT_FD_IN_WIN32(fptr) rb_thread_wait_fd((fptr)->fd);
+#else
+#define WAIT_FD_IN_WIN32(fptr) ;
+#endif
+
#define READ_CHECK(fptr) do {\
if (!READ_DATA_PENDING(fptr)) {\
- rb_thread_wait_fd((fptr)->fd);\
+ WAIT_FD_IN_WIN32(fptr);\
rb_io_check_closed(fptr);\
}\
} while(0)
@@ -1637,8 +1643,7 @@ fill_cbuf(rb_io_t *fptr, int ec_flags)
if (res == econv_source_buffer_empty) {
if (fptr->rbuf_len == 0) {
- rb_thread_wait_fd(fptr->fd);
- rb_io_check_closed(fptr);
+ READ_CHECK(fptr);
if (io_fillbuf(fptr) == -1) {
ds = dp = (unsigned char *)fptr->cbuf + fptr->cbuf_off + fptr->cbuf_len;
de = (unsigned char *)fptr->cbuf + fptr->cbuf_capa;
@@ -2228,8 +2233,7 @@ appendline(rb_io_t *fptr, int delim, VALUE *strp, long *lp)
if (limit == 0)
return (unsigned char)RSTRING_PTR(str)[RSTRING_LEN(str)-1];
}
- rb_thread_wait_fd(fptr->fd);
- rb_io_check_closed(fptr);
+ READ_CHECK(fptr);
} while (io_fillbuf(fptr) >= 0);
*lp = limit;
return EOF;
@@ -2251,8 +2255,7 @@ swallow(rb_io_t *fptr, int term)
if (!read_buffered_data(buf, cnt - i, fptr)) /* must not fail */
rb_sys_fail_path(fptr->pathv);
}
- rb_thread_wait_fd(fptr->fd);
- rb_io_check_closed(fptr);
+ READ_CHECK(fptr);
} while (io_fillbuf(fptr) == 0);
return FALSE;
}
@@ -2290,8 +2293,7 @@ rb_io_getline_fast(rb_io_t *fptr, rb_encoding *enc)
pos += rb_str_coderange_scan_restartable(RSTRING_PTR(str) + pos, RSTRING_PTR(str) + len, enc, &cr);
if (e) break;
}
- rb_thread_wait_fd(fptr->fd);
- rb_io_check_closed(fptr);
+ READ_CHECK(fptr);
if (io_fillbuf(fptr) < 0) {
if (NIL_P(str)) return Qnil;
break;