lib/pitchfork/http_server.rb in pitchfork-0.3.0 vs lib/pitchfork/http_server.rb in pitchfork-0.4.0
- old
+ new
@@ -604,11 +604,14 @@
ensure
body.respond_to?(:close) and body.close
end
unless client.closed? # rack.hijack may've close this for us
- client.shutdown # in case of fork() in Rack app
+ begin
+ client.shutdown # in case of fork() in Rack app
+ rescue Errno::ENOTCONN
+ end
client.close # flush and uncork socket immediately, no keepalive
end
rescue => e
handle_error(client, e)
ensure
@@ -728,13 +731,18 @@
mold = Worker.new(nil, pid: Process.pid, generation: current_generation)
mold.promote!
mold.start_promotion(@control_socket[1])
mold_loop(mold)
end
- true
- ensure
+ rescue
+ # HACK: we need to call this on error or on no error, but not on throw
+ # hence why we don't use `ensure`
+ @promotion_lock.at_fork
+ raise
+ else
@promotion_lock.at_fork # We let the spawned mold own the lock
end
+ true
end
def mold_loop(mold)
readers = init_mold_process(mold)
waiter = prep_readers(readers)