Fire callbacks on render exception too

This commit is contained in:
Tony Garnock-Jones 2012-05-09 21:52:03 -04:00
parent f857f88b7b
commit d66e4eeccc
1 changed files with 9 additions and 3 deletions

View File

@ -397,9 +397,15 @@ let main handle_req (s, peername) =
Queue.add resp.completion_callbacks pending_completion_callbacks;
ignore (Lwt_stream.peek request_stream);
lwt () = render_resp cout req.req_version req.verb resp in
lwt () = discard_unread_body req in
lwt () = Lwt_io.flush cout in
lwt () =
try_lwt
lwt () = render_resp cout req.req_version req.verb resp in
lwt () = discard_unread_body req in
Lwt_io.flush cout
with e ->
lwt () = fire_pending_callbacks () in
raise_lwt e
in
lwt () = fire_pending_callbacks () in
if connection_keepalive req then request_loop () else return ()