From 7c125886b5862bf20711bae22e6697ad46141434 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 25 Oct 2013 19:27:05 +0000 Subject: support SO_REUSEPORT on new listeners (:reuseport) This allows users to start an independent instance of unicorn on a the same port as a running unicorn (as long as both instances use :reuseport). ref: https://lwn.net/Articles/542629/ --- test/unit/test_socket_helper.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/unit/test_socket_helper.rb b/test/unit/test_socket_helper.rb index a38082c..abc177b 100644 --- a/test/unit/test_socket_helper.rb +++ b/test/unit/test_socket_helper.rb @@ -184,4 +184,12 @@ class TestSocketHelper < Test::Unit::TestCase assert_equal 1, cur rescue Errno::EAFNOSUPPORT end if RUBY_VERSION >= "1.9.2" + + def test_reuseport + port = unused_port @test_addr + 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) end -- cgit v1.2.3-24-ge0c7