X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=daemons%2Frdfly%2Frdfly.ml;h=54c87b8d8a43a7481baee5833c25b54a87e41623;hb=832f2e5d4fb9618064437b8ec787df37004e78d9;hp=b9a79d1397da4941f444b678bc6d62d04322e995;hpb=8feb1cda5703daa4371c556593bab63514423a58;p=helm.git diff --git a/daemons/rdfly/rdfly.ml b/daemons/rdfly/rdfly.ml index b9a79d139..54c87b8d8 100644 --- a/daemons/rdfly/rdfly.ml +++ b/daemons/rdfly/rdfly.ml @@ -152,7 +152,7 @@ let password = get_option "rdfly.mysql_connection.password";; let user = get_option "rdfly.mysql_connection.user";; let daemonport = Helm_registry.get_int "rdfly.port";; -let callback (req: Http_types.request) ch = +let callback ((req: Http_types.request), ch) = try debug_print ("Connection from " ^ req#clientAddr) ; debug_print ("Received request: " ^ req#uri) ; @@ -180,11 +180,18 @@ let callback (req: Http_types.request) ch = | exc -> return_html_error ("Uncaught exception: " ^ (Printexc.to_string exc)) ch +let callback req ch = + HExtlib.finally + (fun () -> try close_out ch with Sys_error _ -> ()) + callback (req, ch) + let main () = Sys.catch_break true; try - Http_daemon.start' - ~timeout:(Some 600) ~port:daemonport callback + let d_spec = + Http_daemon.daemon_spec ~timeout:(Some 600) ~port:daemonport ~callback () + in + Http_daemon.main d_spec with Sys.Break -> () in