8000 disable non-blocking pipes and sockets by default · github/ruby@9d74d40 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d74d40

Browse files
author
normal
committed
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
1 parent d7e3043 commit 9d74d40

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

ext/socket/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,15 +435,15 @@ rsock_socket0(int domain, int type, int proto)
435435
static int cloexec_state = -1; /* <0: unknown, 0: ignored, >0: working */
436436

437437
if (cloexec_state > 0) { /* common path, if SOCK_CLOEXEC is defined */
438-
ret = socket(domain, type|SOCK_CLOEXEC|SOCK_NONBLOCK, proto);
438+
ret = socket(domain, type|SOCK_CLOEXEC|RSOCK_NONBLOCK_DEFAULT, proto);
439439
if (ret >= 0) {
440440
if (ret <= 2)
441441
goto fix_cloexec;
442442
goto update_max_fd;
443443
}
444444
}
445445
else if (cloexec_state < 0) { /* usually runs once only for detection */
446-
ret = socket(domain, type|SOCK_CLOEXEC|SOCK_NONBLOCK, proto);
446+
ret = socket(domain, type|SOCK_CLOEXEC|RSOCK_NONBLOCK_DEFAULT, proto);
447447
if (ret >= 0) {
448448
cloexec_state = rsock_detect_cloexec(ret);
449449
if (cloexec_state == 0 || ret <= 2)

ext/socket/rubysocket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
# define RSOCK_NONBLOCK_DEFAULT (0)
3434
#else
35-
# define RSOCK_NONBLOCK_DEFAULT (1)
35+
# define RSOCK_NONBLOCK_DEFAULT (0)
3636
# include <sys/socket.h>
3737
# include <netinet/in.h>
3838
# ifdef HAVE_NETINET_IN_SYSTM_H

ext/socket/socket.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,17 @@ rsock_socketpair0(int domain, int type, int protocol, int sv[2])
175175
{
176176
int ret;
177177
static int cloexec_state = -1; /* <0: unknown, 0: ignored, >0: working */
178+
static const int default_flags = SOCK_CLOEXEC|RSOCK_NONBLOCK_DEFAULT;
178179

179180
if (cloexec_state > 0) { /* common path, if SOCK_CLOEXEC is defined */
180-
ret = socketpair(domain, type|SOCK_CLOEXEC|SOCK_NONBLOCK, protocol, sv);
181+
ret = socketpair(domain, type|default_flags, protocol, sv);
181182
if (ret == 0 && (sv[0] <= 2 || sv[1] <= 2)) {
182183
goto fix_cloexec; /* highly unlikely */
183184
}
184185
goto update_max_fd;
185186
}
186187
else if (cloexec_state < 0) { /* usually runs once only for detection */
187-
ret = socketpair(domain, type|SOCK_CLOEXEC|SOCK_NONBLOCK, protocol, sv);
188+
ret = socketpair(domain, type|default_flags, protocol, sv);
188189
if (ret == 0) {
189190
cloexec_state = rsock_detect_cloexec(sv[0]);
190191
if ((cloexec_state == 0) || (sv[0] <= 2 || sv[1] <= 2))

io.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ off_t __syscall(quad_t number, ...);
138138
#if defined(_WIN32)
139139
# define RUBY_PIPE_NONBLOCK_DEFAULT (0)
140140
#elif defined(O_NONBLOCK)
141-
# define RUBY_PIPE_NONBLOCK_DEFAULT (O_NONBLOCK)
141+
/* disabled for [Bug #15356] (Rack::Deflater + rails) failure: */
142+
# define RUBY_PIPE_NONBLOCK_DEFAULT (0)
142143
#else /* any platforms where O_NONBLOCK does not exist? */
143144
# define RUBY_PIPE_NONBLOCK_DEFAULT (0)
144145
#endif

test/socket/test_basicsocket.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ def test_read_write_nonblock
159159
set_nb = true
160160
buf = String.new
161161
if ssock.respond_to?(:nonblock?)
162-
assert_predicate(ssock, :nonblock?)
163-
assert_predicate(csock, :nonblock?)
162+
assert_not_predicate(ssock, :nonblock?)
163+
assert_not_predicate(csock, :nonblock?)
164164
csock.nonblock = ssock.nonblock = false
165165

166166
# Linux may use MSG_DONTWAIT to avoid setting O_NONBLOCK

0 commit comments

Comments
 (0)
0