about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-10-30 01:50:19 +0000
committerEric Wong <normalperson@yhbt.net>2013-10-30 07:01:03 +0000
commitc1588c5fb232d5425ceaa12258e7b8dd9f1d0cbe (patch)
treefd6688e2af0c6674e2b7bb4faed8dbc4c37614a1 /test
parenta7415f95e30b84fb307d58876d9a70149d73812c (diff)
downloadyahns-c1588c5fb232d5425ceaa12258e7b8dd9f1d0cbe.tar.gz
These are implemented trivially and based on working code, but test
them anyways.
Diffstat (limited to 'test')
-rw-r--r--test/test_server.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/test_server.rb b/test/test_server.rb
index 96dc546..79e498d 100644
--- a/test/test_server.rb
+++ b/test/test_server.rb
@@ -360,6 +360,43 @@ class TestServer < Testcase
     quit_wait(pid)
   end
 
+  def test_ttin_ttou
+    err, cfg, host, port = @err, Yahns::Config.new, @srv.addr[3], @srv.addr[1]
+    ru = lambda { |_|
+      b = "#$$"
+      [ 200, {'Content-Length'=>b.size.to_s}, [b] ]
+    }
+    cfg.instance_eval do
+      GTL.synchronize { app(:rack, ru) { listen "#{host}:#{port}" } }
+      worker_processes 1
+      stderr_path err.path
+    end
+    pid = mkserver(cfg)
+
+    read_pid = lambda do
+      c = get_tcp_client(host, port)
+      c.write("GET /\r\n\r\n")
+      body = Timeout.timeout(10) { c.read }
+      c.close
+      assert_match(/\A\d+\z/, body)
+      body
+    end
+
+    orig_worker_pid = read_pid.call.to_i
+    assert_equal 1, Process.kill(0, orig_worker_pid)
+
+    Process.kill(:TTOU, pid)
+    poke_until_dead(orig_worker_pid)
+
+    Process.kill(:TTIN, pid)
+    second_worker_pid = read_pid.call.to_i
+
+    # PID recycling is rare, hope it doesn't fail here
+    refute_equal orig_worker_pid, second_worker_pid
+  ensure
+    quit_wait(pid)
+  end
+
   def test_mp_hooks
     err = @err
     out = tmpfile(%w(mp_hooks .out))