(* thread action *)
-let callback (req: Http_types.request) outchan =
+let callback ((req: Http_types.request), outchan) =
try
Http_getter_logger.log ("Connection from " ^ req#clientAddr);
Http_getter_logger.log ("Received request: " ^ req#uri);
log_failure msg;
return_html_error ("uncaught_exception", msg) msg outchan)
+let callback req outchan =
+ HExtlib.finally
+ (fun () -> try close_out outchan with Sys_error _ -> ())
+ callback (req, outchan)
+
let batch_update = ref false
let args = [ ]