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

ruby-changes:33019

From: nagachika <ko1@a...>
Date: Sat, 22 Feb 2014 12:01:39 +0900 (JST)
Subject: [ruby-changes:33019] nagachika:r45098 (ruby_2_0_0): merge revision(s) r45066: [Backport #9550]

nagachika	2014-02-22 12:01:21 +0900 (Sat, 22 Feb 2014)

  New Revision: 45098

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

  Log:
    merge revision(s) r45066: [Backport #9550]
    
    * ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error
      (bsock_recvmsg_internal): ditto
    
    * test/socket/test_unix.rb: test above for infinite loop

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/ext/socket/ancdata.c
    branches/ruby_2_0_0/test/socket/test_unix.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 45097)
+++ ruby_2_0_0/ChangeLog	(revision 45098)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sat Feb 22 11:50:52 2014  Eric Wong  <e@8...>
+
+	* ext/socket/ancdata.c (bsock_sendmsg_internal): only retry on error
+	  (bsock_recvmsg_internal): ditto
+	* test/socket/test_unix.rb: test above for infinite loop
+
 Sat Feb 22 11:44:50 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* class.c (rb_mod_init_copy): do nothing if copying self.
Index: ruby_2_0_0/ext/socket/ancdata.c
===================================================================
--- ruby_2_0_0/ext/socket/ancdata.c	(revision 45097)
+++ ruby_2_0_0/ext/socket/ancdata.c	(revision 45098)
@@ -1280,12 +1280,11 @@ bsock_sendmsg_internal(int argc, VALUE * https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/socket/ancdata.c#L1280
 
     ss = rb_sendmsg(fptr->fd, &mh, flags);
 
-    if (!nonblock && rb_io_wait_writable(fptr->fd)) {
-        rb_io_check_closed(fptr);
-        goto retry;
-    }
-
     if (ss == -1) {
+        if (!nonblock && rb_io_wait_writable(fptr->fd)) {
+            rb_io_check_closed(fptr);
+            goto retry;
+        }
         if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
             rb_mod_sys_fail(rb_mWaitWritable, "sendmsg(2) would block");
 	rb_sys_fail("sendmsg(2)");
@@ -1589,12 +1588,11 @@ bsock_recvmsg_internal(int argc, VALUE * https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ext/socket/ancdata.c#L1588
 
     ss = rb_recvmsg(fptr->fd, &mh, flags);
 
-    if (!nonblock && rb_io_wait_readable(fptr->fd)) {
-        rb_io_check_closed(fptr);
-        goto retry;
-    }
-
     if (ss == -1) {
+        if (!nonblock && rb_io_wait_readable(fptr->fd)) {
+            rb_io_check_closed(fptr);
+            goto retry;
+        }
         if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
             rb_mod_sys_fail(rb_mWaitReadable, "recvmsg(2) would block");
 #if defined(HAVE_ST_MSG_CONTROL)
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 45097)
+++ ruby_2_0_0/version.h	(revision 45098)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-02-22"
-#define RUBY_PATCHLEVEL 444
+#define RUBY_PATCHLEVEL 445
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 2
Index: ruby_2_0_0/test/socket/test_unix.rb
===================================================================
--- ruby_2_0_0/test/socket/test_unix.rb	(revision 45097)
+++ ruby_2_0_0/test/socket/test_unix.rb	(revision 45098)
@@ -5,6 +5,7 @@ end https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/socket/test_unix.rb#L5
 
 require "test/unit"
 require "tempfile"
+require "timeout"
 require "tmpdir"
 require "thread"
 require "io/nonblock"
@@ -363,6 +364,28 @@ class TestSocket_UNIXSocket < Test::Unit https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/socket/test_unix.rb#L364
     s2.close if s2
   end
 
+  def test_dgram_pair_sendrecvmsg_errno_set
+    s1, s2 = to_close = UNIXSocket.pair(Socket::SOCK_DGRAM)
+    pipe = IO.pipe
+    to_close.concat(pipe)
+    set_errno = lambda do
+      begin
+        pipe[0].read_nonblock(1)
+        fail
+      rescue => e
+        assert(IO::WaitReadable === e)
+      end
+    end
+    Timeout.timeout(10) do
+      set_errno.call
+      assert_equal(2, s1.sendmsg("HI"))
+      set_errno.call
+      assert_equal("HI", s2.recvmsg[0])
+    end
+  ensure
+    to_close.each(&:close) if to_close
+  end
+
   def test_epipe # [ruby-dev:34619]
     s1, s2 = UNIXSocket.pair
     s1.shutdown(Socket::SHUT_WR)

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45066


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

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