From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS63949 64.71.152.0/24 X-Spam-Status: No, score=-2.2 required=3.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RDNS_NONE,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from 80x24.org (unknown [64.71.152.64]) by dcvr.yhbt.net (Postfix) with ESMTP id E5DA3211B3 for ; Thu, 29 Nov 2018 19:05:33 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] disable non-blocking pipes and sockets by default Date: Thu, 29 Nov 2018 19:05:33 +0000 Message-Id: <20181129190533.13377-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: There seems to be a compatibility problems with Rails + Rack::Deflater; so we revert this incompatibility. This effectively reverts r65922; but keeps the bugfixes to better support non-blocking sockets and pipes for future use. [Bug #15356] [Bug #14968] --- ext/socket/init.c | 4 ++-- ext/socket/rubysocket.h | 2 +- ext/socket/socket.c | 5 +++-- io.c | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/socket/init.c b/ext/socket/init.c index 9742dddec2..44d1506973 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -435,7 +435,7 @@ rsock_socket0(int domain, int type, int proto) static int cloexec_state = -1; /* <0: unknown, 0: ignored, >0: working */ if (cloexec_state > 0) { /* common path, if SOCK_CLOEXEC is defined */ - ret = socket(domain, type|SOCK_CLOEXEC|SOCK_NONBLOCK, proto); + ret = socket(domain, type|SOCK_CLOEXEC|RSOCK_NONBLOCK_DEFAULT, proto); if (ret >= 0) { if (ret <= 2) goto fix_cloexec; @@ -443,7 +443,7 @@ rsock_socket0(int domain, int type, int proto) } } else if (cloexec_state < 0) { /* usually runs once only for detection */ - ret = socket(domain, type|SOCK_CLOEXEC|SOCK_NONBLOCK, proto); + ret = socket(domain, type|SOCK_CLOEXEC|RSOCK_NONBLOCK_DEFAULT, proto); if (ret >= 0) { cloexec_state = rsock_detect_cloexec(ret); if (cloexec_state == 0 || ret <= 2) diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h index 723f09a17c..0ce77a5f6e 100644 --- a/ext/socket/rubysocket.h +++ b/ext/socket/rubysocket.h @@ -32,7 +32,7 @@ */ # define RSOCK_NONBLOCK_DEFAULT (0) #else -# define RSOCK_NONBLOCK_DEFAULT (1) +# define RSOCK_NONBLOCK_DEFAULT (0) # include # include # ifdef HAVE_NETINET_IN_SYSTM_H diff --git a/ext/socket/socket.c b/ext/socket/socket.c index b6bda8fee8..0059595e1b 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -175,16 +175,17 @@ rsock_socketpair0(int domain, int type, int protocol, int sv[2]) { int ret; static int cloexec_state = -1; /* <0: unknown, 0: ignored, >0: working */ + static const int default_flags = SOCK_CLOEXEC|RSOCK_NONBLOCK_DEFAULT; if (cloexec_state > 0) { /* common path, if SOCK_CLOEXEC is defined */ - ret = socketpair(domain, type|SOCK_CLOEXEC|SOCK_NONBLOCK, protocol, sv); + ret = socketpair(domain, type|default_flags, protocol, sv); if (ret == 0 && (sv[0] <= 2 || sv[1] <= 2)) { goto fix_cloexec; /* highly unlikely */ } goto update_max_fd; } else if (cloexec_state < 0) { /* usually runs once only for detection */ - ret = socketpair(domain, type|SOCK_CLOEXEC|SOCK_NONBLOCK, protocol, sv); + ret = socketpair(domain, type|default_flags, protocol, sv); if (ret == 0) { cloexec_state = rsock_detect_cloexec(sv[0]); if ((cloexec_state == 0) || (sv[0] <= 2 || sv[1] <= 2)) diff --git a/io.c b/io.c index d59bde93cf..eeb4d66063 100644 --- a/io.c +++ b/io.c @@ -138,7 +138,8 @@ off_t __syscall(quad_t number, ...); #if defined(_WIN32) # define RUBY_PIPE_NONBLOCK_DEFAULT (0) #elif defined(O_NONBLOCK) -# define RUBY_PIPE_NONBLOCK_DEFAULT (O_NONBLOCK) + /* disabled for [Bug #15356] (Rack::Deflater + rails) failure: */ +# define RUBY_PIPE_NONBLOCK_DEFAULT (0) #else /* any platforms where O_NONBLOCK does not exist? */ # define RUBY_PIPE_NONBLOCK_DEFAULT (0) #endif -- EW