about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-10-25 19:27:05 +0000
committerEric Wong <normalperson@yhbt.net>2013-10-25 20:00:37 +0000
commit7c125886b5862bf20711bae22e6697ad46141434 (patch)
tree17e08b48ff591ab43a369067a3c23c6e0dbcb3c3 /test
parent1dc099228ee0f59c13385a3e7346a2cb37d85153 (diff)
downloadunicorn-7c125886b5862bf20711bae22e6697ad46141434.tar.gz
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/
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_socket_helper.rb8
1 files changed, 8 insertions, 0 deletions
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