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

ruby-changes:21591

From: akr <ko1@a...>
Date: Sat, 5 Nov 2011 18:06:14 +0900 (JST)
Subject: [ruby-changes:21591] akr:r33640 (trunk): * ext/socket/socket.c (rsock_socketpair0): refactored.

akr	2011-11-05 18:06:05 +0900 (Sat, 05 Nov 2011)

  New Revision: 33640

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

  Log:
    * ext/socket/socket.c (rsock_socketpair0): refactored.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/socket.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33639)
+++ ChangeLog	(revision 33640)
@@ -1,3 +1,7 @@
+Sat Nov  5 18:05:12 2011  Tanaka Akira  <akr@f...>
+
+	* ext/socket/socket.c (rsock_socketpair0): refactored.
+
 Sat Nov  5 17:55:52 2011  Tanaka Akira  <akr@f...>
 
 	* ext/socket/init.c (rsock_socket0): don't clear try_sock_cloexec if
Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c	(revision 33639)
+++ ext/socket/socket.c	(revision 33640)
@@ -86,17 +86,15 @@
     static int try_sock_cloexec = 1;
     if (try_sock_cloexec) {
         ret = socketpair(domain, type|SOCK_CLOEXEC, protocol, sv);
-        if (ret == -1) {
+        if (ret == -1 && errno == EINVAL) {
             /* SOCK_CLOEXEC is available since Linux 2.6.27.  Linux 2.6.18 fails with EINVAL */
-            if (try_sock_cloexec && errno == EINVAL) {
-                ret = socketpair(domain, type, protocol, sv);
-                if (ret != -1) {
-                    /* The reason of EINVAL may be other than SOCK_CLOEXEC.
-                     * So disable SOCK_CLOEXEC only if socketpair() succeeds without SOCK_CLOEXEC.
-                     * Ex. Socket.pair(:UNIX, 0xff) fails with EINVAL.
-                     */
-                    try_sock_cloexec = 0;
-                }
+            ret = socketpair(domain, type, protocol, sv);
+            if (ret != -1) {
+                /* The reason of EINVAL may be other than SOCK_CLOEXEC.
+                 * So disable SOCK_CLOEXEC only if socketpair() succeeds without SOCK_CLOEXEC.
+                 * Ex. Socket.pair(:UNIX, 0xff) fails with EINVAL.
+                 */
+                try_sock_cloexec = 0;
             }
         }
     }

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

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