]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/DEVEL/ocaml-http/http_daemon.ml
ocaml 3.09 transition
[helm.git] / helm / DEVEL / ocaml-http / http_daemon.ml
index 60f186cd43c509309c2e3c638b62e5a638f69e4e..629d1286cfd7ea97be793e28bb01b8b891591455 100644 (file)
@@ -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;