diff options
-rw-r--r-- | ext/socket/init.c | 12 | ||||
-rw-r--r-- | ext/socket/rubysocket.h | 6 | ||||
-rw-r--r-- | ext/socket/socket.c | 12 |
3 files changed, 23 insertions, 7 deletions
diff --git a/ext/socket/init.c b/ext/socket/init.c index ba4b084837..9742dddec2 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -466,7 +466,9 @@ rsock_socket0(int domain, int type, int proto) 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 proto) 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 sockaddr *address, socklen_t *address_len, #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) { diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h index bccea8732f..723f09a17c 100644 --- a/ext/socket/rubysocket.h +++ b/ext/socket/rubysocket.h @@ -26,7 +26,13 @@ # 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 diff --git a/ext/socket/socket.c b/ext/socket/socket.c index ad2ca5fc67..b6bda8fee8 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -213,8 +213,10 @@ rsock_socketpair0(int domain, int type, int protocol, int sv[2]) 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, int protocol, int sv[2]) 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 */ |