diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-11-06 17:59:25 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-11-06 18:52:55 +0000 |
commit | a32d80a93101b884c44991247b8278002368d483 (patch) | |
tree | e7c8ceedffccbf33d023d9a6f7267886072e66ee /extras/exec_cgi.rb | |
parent | 52f2a4055a0f7e27df02d40bb42dda446dcdf89d (diff) | |
download | yahns-a32d80a93101b884c44991247b8278002368d483.tar.gz |
We can use the wbuf_close return value instead to ensure we close tmpio properly and follow the same code path as a normal (:wait_writable-triggering) buffered response would. Add a few tests to ensure we properly close the response body for exec_cgi, where I noticed zombies and started me down this rabbit hole looking for places where the response body was not closed properly.
Diffstat (limited to 'extras/exec_cgi.rb')
-rw-r--r-- | extras/exec_cgi.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/extras/exec_cgi.rb b/extras/exec_cgi.rb index 083047e..170e773 100644 --- a/extras/exec_cgi.rb +++ b/extras/exec_cgi.rb @@ -67,7 +67,8 @@ class ExecCgi PASS_VARS.each { |key| val = env[key] and cgi_env[key] = val } env.each { |key,val| cgi_env[key] = val if key =~ /\AHTTP_/ } pipe = MyIO.pipe - pipe[0].my_pid = Process.spawn(cgi_env, *@args, + errbody = pipe[0] + errbody.my_pid = Process.spawn(cgi_env, *@args, out: pipe[1], close_others: true) pipe[1].close pipe = pipe[0] @@ -100,9 +101,12 @@ class ExecCgi pipe.chunked = true end end + errbody = nil [ status, headers, pipe ] else [ 500, { "Content-Length" => "0", "Content-Type" => "text/plain" }, [] ] end + ensure + errbody.close if errbody end end |