diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-10-20 00:50:26 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-20 00:50:26 +0000 |
commit | 5de2a9567f73d38e3492db2ae40b6c332c9aacd6 (patch) | |
tree | cf95585ea62a7035f5e3f85ea14913d55c0fffd3 /lib/yahns/socket_helper.rb | |
parent | 2231035fd7a73629123eb76438ffabbefa807ad7 (diff) | |
download | yahns-5de2a9567f73d38e3492db2ae40b6c332c9aacd6.tar.gz |
This means ruby 1.9.3 should be supported, as well as Ruby implementations which do not set the close-on-exec flag by default. Note: this is only best-effort outside of modern Linux with threads, since a multithreaded process may create and inadvertantly share descriptors. This is why Linux supports O_CLOEXEC, SOCK_CLOEXEC and friends, as kernel support is the only way to sanely fix this.
Diffstat (limited to 'lib/yahns/socket_helper.rb')
-rw-r--r-- | lib/yahns/socket_helper.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/yahns/socket_helper.rb b/lib/yahns/socket_helper.rb index 61f2b0f..62a6da2 100644 --- a/lib/yahns/socket_helper.rb +++ b/lib/yahns/socket_helper.rb @@ -5,6 +5,7 @@ module Yahns::SocketHelper # :nodoc: def set_server_sockopt(sock, opt) opt = {backlog: 1024}.merge!(opt) if opt + sock.close_on_exec = true TCPSocket === sock and sock.setsockopt(:IPPROTO_TCP, :TCP_NODELAY, 1) sock.setsockopt(:SOL_SOCKET, :SO_KEEPALIVE, 1) |