X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fhbugs%2Fbroker.ml;h=6b62af94660b40cb06f436918e0194a34a56d89b;hb=97c2d258a5c524eb5c4b85208899d80751a2c82f;hp=2ff8b98349dbf11853fbff1b676b706195b7c0df;hpb=a21777bd2ac02fd346f168ead468405e4c300855;p=helm.git diff --git a/helm/ocaml/hbugs/broker.ml b/helm/ocaml/hbugs/broker.ml index 2ff8b9834..6b62af946 100644 --- a/helm/ocaml/hbugs/broker.ml +++ b/helm/ocaml/hbugs/broker.ml @@ -30,8 +30,7 @@ open Hbugs_types;; open Printf;; let debug = true ;; -let debug_print s = if debug then prerr_endline s ;; -Http_common.debug := false;; +let debug_print s = if debug then prerr_endline (Lazy.force s) ;; let daemon_name = "H-Bugs Broker" ;; let default_port = 49081 ;; @@ -67,13 +66,13 @@ let do_critical = let mutex = Mutex.create () in fun action -> try -(* debug_print "Acquiring lock ..."; *) +(* debug_print (lazy "Acquiring lock ..."); *) Mutex.lock mutex; -(* debug_print "Lock Acquired!"; *) +(* debug_print (lazy "Lock Acquired!"); *) let res = Lazy.force action in -(* debug_print "Releaseing lock ..."; *) +(* debug_print (lazy "Releaseing lock ..."); *) Mutex.unlock mutex; -(* debug_print "Lock released!"; *) +(* debug_print (lazy "Lock released!"); *) res with e -> Mutex.unlock mutex; raise e ;; @@ -233,7 +232,7 @@ let handle_msg outchan msg = )) | msg -> (* unexpected message *) - debug_print "Unknown message!"; + debug_print (lazy "Unknown message!"); Hbugs_messages.respond_exc "unexpected_msg" (Hbugs_messages.string_of_msg msg) outchan) in @@ -242,7 +241,7 @@ let handle_msg outchan = if debug then (fun msg -> (* filter handle_msg through a function which dumps input messages *) - debug_print (Hbugs_messages.string_of_msg msg); + debug_print (lazy (Hbugs_messages.string_of_msg msg)); handle_msg outchan msg) else handle_msg outchan @@ -252,8 +251,8 @@ in (* thread action *) let callback (req: Http_types.request) outchan = try - debug_print ("Connection from " ^ req#clientAddr); - debug_print ("Received request: " ^ req#path); + debug_print (lazy ("Connection from " ^ req#clientAddr)); + debug_print (lazy ("Received request: " ^ req#path)); (match req#path with (* TODO write help message *) | "/help" -> return_xml_msg " not yet written " outchan @@ -266,7 +265,7 @@ let callback (req: Http_types.request) outchan = else Http_daemon.respond_error ~code:400 outchan | _ -> Http_daemon.respond_error ~code:400 outchan); - debug_print "Done!\n" + debug_print (lazy "Done!\n") with | Http_types.Param_not_found attr_name -> Hbugs_messages.respond_exc "missing_parameter" attr_name outchan