diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-11-04 18:28:46 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-11-04 18:28:46 +0000 |
commit | a1aa5c97289df09a90831c4d9bf6e22ac351bdd8 (patch) | |
tree | 1b5904f2effe8ae93d53662b5328758ce146a4c9 /test/unit | |
parent | 9c8747d290dfc7ab4bc11c4f88b3c284cc5ba949 (diff) | |
download | unicorn-a1aa5c97289df09a90831c4d9bf6e22ac351bdd8.tar.gz |
On BSD-derived platforms the getsockopt true value may be any (>= 0) value, not just one as it is on Linux. Additionally, SO_REUSEPORT is only supported since Linux 3.9, so folks on older kernels may not have it available. We still define it for Linux since kernel upgrades are usually more common than glibc upgrades. Note: we will still raise an exception at runtime if a user explicitly requests :reuseport in their config and runs an older Linux kernel. Reported-by: Andrew Hobson <ahobson@gmail.com>
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/test_socket_helper.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/unit/test_socket_helper.rb b/test/unit/test_socket_helper.rb index abc177b..8992757 100644 --- a/test/unit/test_socket_helper.rb +++ b/test/unit/test_socket_helper.rb @@ -190,6 +190,8 @@ class TestSocketHelper < Test::Unit::TestCase name = "#@test_addr:#{port}" sock = bind_listen(name, :reuseport => true) cur = sock.getsockopt(Socket::SOL_SOCKET, SO_REUSEPORT).unpack('i')[0] - assert_equal 1, cur - end if defined?(SO_REUSEPORT) + assert_operator cur, :>, 0 + rescue Errno::ENOPROTOOPT + # kernel does not support SO_REUSEPORT (older Linux) + end end |