about summary refs log tree commit homepage
path: root/t/oob_gc.ru
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-04-29 15:48:35 -0700
committerEric Wong <normalperson@yhbt.net>2011-04-30 01:45:55 +0000
commitfe0dd93cd9cb97b46f6cfb4b1e370e38717a93f0 (patch)
tree5e5c45c385ade1bad0e0c6ec6e5eedd379181275 /t/oob_gc.ru
parentd385bc4f3ed7b783b7414f5d34299bd2bf242fe6 (diff)
downloadunicorn-fe0dd93cd9cb97b46f6cfb4b1e370e38717a93f0.tar.gz
This was broken since v3.3.1[1] and v1.1.6[2] since nginx relies on
a closed socket (and not Content-Length/Transfer-Encoding) to
detect a response completion.  We have to close the client
socket before invoking GC to ensure the client sees the response
in a timely manner.

[1] - commit b72a86f66c722d56a6d77ed1d2779ace6ad103ed
[2] - commit b7a0074284d33352bb9e732c660b29162f34bf0e

(cherry picked from commit faeb3223636c39ea8df4017dc9a9d39ac649b26d)

Conflicts:

	examples/big_app_gc.rb
	lib/unicorn/oob_gc.rb
Diffstat (limited to 't/oob_gc.ru')
-rw-r--r--t/oob_gc.ru21
1 files changed, 21 insertions, 0 deletions
diff --git a/t/oob_gc.ru b/t/oob_gc.ru
new file mode 100644
index 0000000..c6035b6
--- /dev/null
+++ b/t/oob_gc.ru
@@ -0,0 +1,21 @@
+#\-E none
+require 'unicorn/oob_gc'
+use Rack::ContentLength
+use Rack::ContentType, "text/plain"
+use Unicorn::OobGC
+$gc_started = false
+
+# Mock GC.start
+def GC.start
+  ObjectSpace.each_object(BasicSocket) do |x|
+    next if Unicorn::HttpServer::LISTENERS.include?(x)
+    x.closed? or abort "not closed #{x}"
+  end
+  $gc_started = true
+end
+run lambda { |env|
+  if "/gc_reset" == env["PATH_INFO"] && "POST" == env["REQUEST_METHOD"]
+    $gc_started = false
+  end
+  [ 200, {}, [ "#$gc_started\n" ] ]
+}