1. Dmitry Grebeniuk
  2. amall

Commits

Dmitry Grebeniuk  committed 2e80b32

debug closing

  • Participants
  • Parent commits be4a6c7
  • Branches default

Comments (0)

Files changed (1)

File src/amall_http_server.ml

View file
  • Ignore whitespace
  (userfunc : request -> (segpath * H.service_desc))
  (inch, outch)
 : unit
-= IO.run_and_ignore_result
+=
+IO.run_and_ignore_result (
+  let string_of_exn e =
+            (loop e
+             where rec loop e =
+               match e with
+               [ I.Iteratees_err_msg e -> "it/" ^ loop e
+               | Ws_service_error e -> "wssrv/" ^ loop e
+               | _ -> Printexc.to_string e
+               ]
+            )
+  in
+try
    (let closed = ref False in
     let do_close () =
       let () = dbg "http_server_func: close 0" in
              let () = closed.val := True in
              let () = dbg "http_server_func: close 1" in
              IO.close_in inch >>% fun () ->
-             let () = dbg "http_server_func: close 1" in
+             let () = dbg "http_server_func: close 2" in
              IO.close_out outch >>% fun () ->
-             let () = dbg "http_server_func: close 1" in
+             let () = dbg "http_server_func: close 3" in
              IO.return ()
           )
           (fun e ->
       )
       (fun e ->
         ( Printf.eprintf "amall http: exception: %s\n%!" &
-            (loop e
-             where rec loop e =
-               match e with
-               [ I.Iteratees_err_msg e -> "it/" ^ loop e
-               | Ws_service_error e -> "wssrv/" ^ loop e
-               | _ -> Printexc.to_string e
-               ]
-            )
+            string_of_exn e
         ; do_close ()
         )
       )
    )
+with [e -> ( Printf.eprintf "amall http: uncaught exception: %s\n%!" &
+               string_of_exn e
+           ; IO.return ()
+           )
+     ]
+)
 ;