X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Finterface%2FxsltProcessor.ml;fp=helm%2Finterface%2FxsltProcessor.ml;h=0000000000000000000000000000000000000000;hb=fa11ed6dc134f8ad3421c37a97271018e075bbed;hp=c82a8f5f8c960e0c94d8b99c1eccf4baa8be9a05;hpb=c03d2c1fdab8d228cb88aaba5ca0f556318bebc5;p=helm.git diff --git a/helm/interface/xsltProcessor.ml b/helm/interface/xsltProcessor.ml deleted file mode 100644 index c82a8f5f8..000000000 --- a/helm/interface/xsltProcessor.ml +++ /dev/null @@ -1,64 +0,0 @@ -exception XsltProcessorCouldNotSend;; -exception XsltProcessorCouldNotReceive;; - -let portserver = 12345;; -let portclient = 12346;; -let time_to_wait = 10;; - -let rec process uri usecache mode = - let module U = Unix in - let uri = UriManager.string_of_uri uri in - let pid = string_of_int (U.getpid ()) - and filename' = - let uri' = Str.replace_first (Str.regexp ".*:") "" uri in - Str.global_replace (Str.regexp "/") "_" - (Str.global_replace (Str.regexp "_") "__" uri') - in let tmpfile = "/tmp/helm_" ^ filename' ^ "_" ^ pid in - (* test if the cache can be used *) - let tmp_file_exists = Sys.file_exists tmpfile in - if usecache && tmp_file_exists then - tmpfile - else - let url = Configuration.getter_url ^ uri in - (* purge the cache if asked to *) - if not usecache && tmp_file_exists then - Sys.remove tmpfile ; - let string_to_send = mode ^ " " ^ url ^ " " ^ tmpfile in - (* next function is for looping in case the server is not responding *) - let rec contact_server () = - let socketclient = U.socket U.PF_INET U.SOCK_DGRAM 0 - and socketserver = U.socket U.PF_INET U.SOCK_DGRAM 0 in - let bounded = ref false in - while not !bounded do - try - U.bind socketclient (U.ADDR_INET(U.inet_addr_any,portclient)) ; - bounded := true - with _ -> - print_endline "Port unavailable. Retrying..." ; flush stdout ; - U.sleep 5 (* wait hoping the inetaddr is released *) - done ; - let n = - U.sendto socketserver string_to_send 0 (String.length string_to_send) - [] (U.ADDR_INET(U.inet_addr_any,portserver)) - in - if n = -1 then raise XsltProcessorCouldNotSend ; - U.close socketserver ; - let process_signal _ = U.close socketclient in - Sys.set_signal Sys.sigalrm (Sys.Signal_handle process_signal) ; - (* if the server does not respond, repeat the query *) - ignore (U.alarm time_to_wait) ; - try - if U.recv socketclient "" 0 0 [] = -1 then - raise XsltProcessorCouldNotReceive ; - ignore (U.alarm 0) ; (* stop the bomb *) - Sys.set_signal Sys.sigalrm Sys.Signal_default ; - U.close socketclient ; - tmpfile - with - U.Unix_error(_,"recv",_) -> - print_endline "Xaland server not responding. Retrying..." ; - flush stdout; - contact_server () - in - contact_server () -;;