From 9c62f882f0aa158c0954442fe544d85e68dd10c3 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Mon, 29 May 2006 17:24:43 +0000 Subject: [PATCH] ensure connections get closed after having been served --- helm/software/daemons/graphs/tools/drawGraph.ml | 7 ++++++- helm/software/daemons/graphs/tools/uriSetQueue.ml | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/helm/software/daemons/graphs/tools/drawGraph.ml b/helm/software/daemons/graphs/tools/drawGraph.ml index c17902fbc..f7c817496 100644 --- a/helm/software/daemons/graphs/tools/drawGraph.ml +++ b/helm/software/daemons/graphs/tools/drawGraph.ml @@ -56,7 +56,7 @@ let string_of_exit_status = function | Unix.WSIGNALED n -> sprintf "Process killed by signal %d" n | Unix.WSTOPPED n -> sprintf "Process stopped by signal %d" n in -let callback (req: Http_types.request) outchan = +let callback ((req: Http_types.request), outchan) = try (match req#path with | "/draw" -> @@ -90,6 +90,11 @@ let callback (req: Http_types.request) outchan = ~body:(sprintf "Parameter '%s' is missing" attr_name) outchan in +let callback req ch = + HExtlib.finally + (fun () -> try close_out ch with Sys_error _ -> ()) + callback (req, ch) +in Helm_registry.load_from configuration_file; let port = Helm_registry.get_int "draw_graph.port" in Sys.chdir (Helm_registry.get "draw_graph.dir"); diff --git a/helm/software/daemons/graphs/tools/uriSetQueue.ml b/helm/software/daemons/graphs/tools/uriSetQueue.ml index 430275800..86bfe35f3 100644 --- a/helm/software/daemons/graphs/tools/uriSetQueue.ml +++ b/helm/software/daemons/graphs/tools/uriSetQueue.ml @@ -76,7 +76,7 @@ let queue_mem item queue = (* mem function over queues *) with Found -> true ;; -let callback (req: Http_types.request) outchan = +let callback ((req: Http_types.request), outchan) = try let res = new Http_response.response () in res#addBasicHeaders; @@ -181,6 +181,13 @@ let callback (req: Http_types.request) outchan = outchan in +let callback req ch = + HExtlib.finally + (fun () -> try close_out ch with Sys_error _ -> ()) + callback (req, ch) + +in + Helm_registry.load_from configuration_file; let port = Helm_registry.get_int "uri_set_queue.port" in printf "%s started and listening on port %d\n" daemon_name port; -- 2.39.2