[前][次][番号順一覧][スレッド一覧]

ruby-changes:14764

From: mame <ko1@a...>
Date: Tue, 9 Feb 2010 22:37:13 +0900 (JST)
Subject: [ruby-changes:14764] Ruby:r26625 (trunk): * io.c (READ_CHECK): do not select fd before reading, that had made

mame	2010-02-09 22:27:04 +0900 (Tue, 09 Feb 2010)

  New Revision: 26625

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26625

  Log:
    * io.c (READ_CHECK): do not select fd before reading, that had made
      TCPServer#gets stuck.  [ruby-dev:40317]

  Modified files:
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26624)
+++ ChangeLog	(revision 26625)
@@ -1,3 +1,8 @@
+Tue Feb  9 22:23:27 2010  Yusuke Endoh  <mame@t...>
+
+	* 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@t...>
 
 	* lib/rexml/text.rb (REXML::Text#initialize): REXML::Text.new checks
Index: io.c
===================================================================
--- io.c	(revision 26624)
+++ io.c	(revision 26625)
@@ -175,9 +175,15 @@
 #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 @@
 
         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 @@
 	    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 @@
 	    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 @@
 		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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]