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

ruby-changes:53713

From: normal <ko1@a...>
Date: Fri, 23 Nov 2018 05:02:42 +0900 (JST)
Subject: [ruby-changes:53713] normal:r65929 (trunk): socket: disable nonblocking-by-default on win32

normal	2018-11-23 05:02:36 +0900 (Fri, 23 Nov 2018)

  New Revision: 65929

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65929

  Log:
    socket: disable nonblocking-by-default on win32
    
    Perhaps this fixes test failures reported by Greg and k0kubun.
    
    However, the failure of certain tests to handle non-blocking I/O
    seems to indicate pre-existing problems on win32 platforms.
    Somebody knowledgeable about win32 should be able to fix it.
    
    [ruby-core:89973] [ruby-core:89976] [ruby-core:89977] [Bug #14968]

  Modified files:
    trunk/ext/socket/init.c
    trunk/ext/socket/rubysocket.h
    trunk/ext/socket/socket.c
Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c	(revision 65928)
+++ ext/socket/socket.c	(revision 65929)
@@ -213,8 +213,10 @@ rsock_socketpair0(int domain, int type, https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L213
 fix_cloexec:
     rb_maygvl_fd_fix_cloexec(sv[0]);
     rb_maygvl_fd_fix_cloexec(sv[1]);
-    rsock_make_fd_nonblock(sv[0]);
-    rsock_make_fd_nonblock(sv[1]);
+    if (RSOCK_NONBLOCK_DEFAULT) {
+        rsock_make_fd_nonblock(sv[0]);
+        rsock_make_fd_nonblock(sv[1]);
+    }
 
 update_max_fd:
     rb_update_max_fd(sv[0]);
@@ -233,8 +235,10 @@ rsock_socketpair0(int domain, int type, https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L235
 
     rb_fd_fix_cloexec(sv[0]);
     rb_fd_fix_cloexec(sv[1]);
-    rsock_make_fd_nonblock(sv[0]);
-    rsock_make_fd_nonblock(sv[1]);
+    if (RSOCK_NONBLOCK_DEFAULT) {
+        rsock_make_fd_nonblock(sv[0]);
+        rsock_make_fd_nonblock(sv[1]);
+    }
     return ret;
 }
 #endif /* !SOCK_CLOEXEC */
Index: ext/socket/rubysocket.h
===================================================================
--- ext/socket/rubysocket.h	(revision 65928)
+++ ext/socket/rubysocket.h	(revision 65929)
@@ -26,7 +26,13 @@ https://github.com/ruby/ruby/blob/trunk/ext/socket/rubysocket.h#L26
 #  if defined(_MSC_VER)
 #    undef HAVE_TYPE_STRUCT_SOCKADDR_DL
 #  endif
+/*
+ * FIXME: failures if we make nonblocking the default
+ * [ruby-core:89973] [ruby-core:89976] [ruby-core:89977] [Bug #14968]
+ */
+#  define RSOCK_NONBLOCK_DEFAULT (0)
 #else
+#  define RSOCK_NONBLOCK_DEFAULT (1)
 #  include <sys/socket.h>
 #  include <netinet/in.h>
 #  ifdef HAVE_NETINET_IN_SYSTM_H
Index: ext/socket/init.c
===================================================================
--- ext/socket/init.c	(revision 65928)
+++ ext/socket/init.c	(revision 65929)
@@ -466,7 +466,9 @@ rsock_socket0(int domain, int type, int https://github.com/ruby/ruby/blob/trunk/ext/socket/init.c#L466
         return -1;
 fix_cloexec:
     rb_maygvl_fd_fix_cloexec(ret);
-    rsock_make_fd_nonblock(ret);
+    if (RSOCK_NONBLOCK_DEFAULT) {
+        rsock_make_fd_nonblock(ret);
+    }
 update_max_fd:
     rb_update_max_fd(ret);
 
@@ -481,7 +483,9 @@ rsock_socket0(int domain, int type, int https://github.com/ruby/ruby/blob/trunk/ext/socket/init.c#L483
     if (ret == -1)
         return -1;
     rb_fd_fix_cloexec(ret);
-    rsock_make_fd_nonblock(ret);
+    if (RSOCK_NONBLOCK_DEFAULT) {
+        rsock_make_fd_nonblock(ret);
+    }
 
     return ret;
 }
@@ -661,7 +665,9 @@ cloexec_accept(int socket, struct sockad https://github.com/ruby/ruby/blob/trunk/ext/socket/init.c#L665
 #ifdef HAVE_ACCEPT4
     static int try_accept4 = 1;
 #endif
-    nonblock = 1; /* TODO remove parameter */
+    if (RSOCK_NONBLOCK_DEFAULT) {
+        nonblock = 1;
+    }
     if (address_len) len0 = *address_len;
 #ifdef HAVE_ACCEPT4
     if (try_accept4) {

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

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