From: Stefano Zacchiroli Date: Wed, 14 Sep 2005 16:06:14 +0000 (+0000) Subject: fixed a finalization issue for connections closed twice X-Git-Tag: V_0_1_2_1~1 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=33a02e0b639217093eb63f30169aaa6ac8c78907;p=helm.git fixed a finalization issue for connections closed twice thanks to Erik Stroke for the patch --- diff --git a/helm/DEVEL/ocaml-http/debian/changelog b/helm/DEVEL/ocaml-http/debian/changelog index 80e1e4259..c7f6e581d 100644 --- a/helm/DEVEL/ocaml-http/debian/changelog +++ b/helm/DEVEL/ocaml-http/debian/changelog @@ -1,3 +1,11 @@ +ocaml-http (0.1.2-1) unstable; urgency=low + + * avoid exceptions for closing connection twice during finaliztion of + connection objects (thanks to Eric Strokes + for the patch) + + -- Stefano Zacchiroli Wed, 14 Sep 2005 18:03:40 +0200 + ocaml-http (0.1.1-1) unstable; urgency=low * added ?default parameter to "param" method diff --git a/helm/DEVEL/ocaml-http/http_daemon.ml b/helm/DEVEL/ocaml-http/http_daemon.ml index 60f186cd4..629d1286c 100644 --- a/helm/DEVEL/ocaml-http/http_daemon.ml +++ b/helm/DEVEL/ocaml-http/http_daemon.ml @@ -26,6 +26,8 @@ open Http_types open Http_constants open Http_parser +exception Http_daemon_failure of string + (** send raw data on outchan, flushing it afterwards *) let send_raw ~data outchan = output_string outchan data; @@ -408,13 +410,13 @@ module Trivial = let main spec = main { spec with callback = trivial_callback } end - (* @param inchan input channel connected to client + (** @param inchan input channel connected to client @param outchan output channel connected to client @param sockaddr client socket address *) class connection inchan outchan sockaddr = (* ASSUMPTION: inchan and outchan are channels built on top of the same Unix.file_descr thus closing one of them will close also the other *) - let close' o = o#close in + let close' o = try o#close with Http_daemon_failure _ -> () in object (self) initializer Gc.finalise close' self @@ -423,7 +425,8 @@ class connection inchan outchan sockaddr = method private assertNotClosed = if closed then - failwith "Http_daemon.connection: connection is closed" + raise (Http_daemon_failure + "Http_daemon.connection: connection is closed") method getRequest = self#assertNotClosed;