From d66e4eeccc6d5da88a2612c9a4eae9293cfb6821 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 9 May 2012 21:52:03 -0400 Subject: [PATCH] Fire callbacks on render exception too --- httpd.ml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/httpd.ml b/httpd.ml index 1986e8f..c1f42af 100644 --- a/httpd.ml +++ b/httpd.ml @@ -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 ()