From: normalperson@... Date: 2015-07-02T01:30:19+00:00 Subject: [ruby-core:69835] [Ruby trunk - Feature #11139] [PATCH] socket: support accept `sock_nonblock: (true|false)' Issue #11139 has been updated by Eric Wong. File socket-support-accept-sock_nonblock-true-false-v2.patch added Subject changed from [PATCH] socket: accept_nonblock supports "nonblock: false" kwarg to [PATCH] socket: support accept `sock_nonblock: (true|false)' Description updated I think we need to preserve existing behavior with accept_nonblock in case there is code which shares accepted FDs with non-Ruby processes (or even passes it to a C extension). ---------------------------------------- Feature #11139: [PATCH] socket: support accept `sock_nonblock: (true|false)' https://bugs.ruby-lang.org/issues/11139#change-53233 * Author: Eric Wong * Status: Feedback * Priority: Normal * Assignee: Akira Tanaka ---------------------------------------- An application wanting to do non-blocking accept may want to create a blocking accepted socket, allow it with a kwarg while preserving default behavior. This is analogous to the SOCK_NONBLOCK flag in the Linux `accept4' syscall. While this has little obvious effect for Ruby API users (which can emulate blocking behavior) this will reduce syscalls made internally by Ruby. Forcing blocking will preserve "wake-one" behavior in the OS kernel to avoid a "thundering herd" problem. In all cases, existing Ruby 2.2 behavior is preserved by default to maximize compatibility, especially when sharing sockets with non-Ruby processes: `accept' and `sysaccept' calls will create sockets which are blocking by default. `accept_nonblock', calls will create sockets which are non-blocking by default. ---Files-------------------------------- 0002-socket-accept_nonblock-supports-nonblock-false-kwarg.patch (2.94 KB) socket-support-accept-sock_nonblock-true-false-v2.patch (20.8 KB) -- https://bugs.ruby-lang.org/