summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-29 20:00:00 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-29 20:00:00 +0000
commit9d74d402e15008c10f80e67595cc861c89a1636b (patch)
tree71d73fd903c5047f889aedb1e0cdf98d59bc8175
parentd7e3043463e7e138a4334b2173d6a3fbe4321e35 (diff)
disable non-blocking pipes and sockets by default
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/socket/init.c4
-rw-r--r--ext/socket/rubysocket.h2
-rw-r--r--ext/socket/socket.c5
-rw-r--r--io.c3
-rw-r--r--test/socket/test_basicsocket.rb4
5 files changed, 10 insertions, 8 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 <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 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
diff --git a/test/socket/test_basicsocket.rb b/test/socket/test_basicsocket.rb
index 71d8fd66c1..c8e9b23f83 100644
--- a/test/socket/test_basicsocket.rb
+++ b/test/socket/test_basicsocket.rb
@@ -159,8 +159,8 @@ class TestSocket_BasicSocket < Test::Unit::TestCase
set_nb = true
buf = String.new
if ssock.respond_to?(:nonblock?)
- assert_predicate(ssock, :nonblock?)
- assert_predicate(csock, :nonblock?)
+ assert_not_predicate(ssock, :nonblock?)
+ assert_not_predicate(csock, :nonblock?)
csock.nonblock = ssock.nonblock = false
# Linux may use MSG_DONTWAIT to avoid setting O_NONBLOCK