* 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
This commit is contained in:
mame 2010-02-09 13:27:04 +00:00
Родитель f2bd994409
Коммит b4f90b236c
2 изменённых файлов: 16 добавлений и 9 удалений

Просмотреть файл

@ -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

20
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;