summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog5
-rw-r--r--io.c20
2 files changed, 16 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 8c5c37ac212..600803c29e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Feb 9 22:23:27 2010 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * io.c (READ_CHECK): do not select fd before reading, that had made
+ TCPServer#gets stuck. [ruby-dev:40317]
+
Tue Feb 9 21:27:38 2010 Yusuke Endoh <mame@tsg.ne.jp>
* lib/rexml/text.rb (REXML::Text#initialize): REXML::Text.new checks
diff --git a/io.c b/io.c
index 8926c315f1a..da3fc7bb7b9 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;