X-Git-Url: http://git.onelab.eu/?p=vsys.git;a=blobdiff_plain;f=unixsocketwatcher.ml;h=9a0fc90cdfaca5f99eb9be652ced85c90f89eb40;hp=6ef359ab552551d9b2ef5c52ffcc07a55ac02257;hb=b8b329f72fa44685bbd522cb5312dd19d352f580;hpb=9ec649e8f697ffba675a6a2b7b959e89f80f4eab diff --git a/unixsocketwatcher.ml b/unixsocketwatcher.ml index 6ef359a..9a0fc90 100644 --- a/unixsocketwatcher.ml +++ b/unixsocketwatcher.ml @@ -15,24 +15,12 @@ open Printf let close_if_open fd = (try (ignore(close fd);) with _ -> ()) -type in_pathname = string -type directory = string -type base_pathname = string +type control_path_name = string type slice_name = string -let unix_socket_table: (in_pathname,(directory*base_pathname*slice_name*Unix.file_descr) option) Hashtbl.t = +let unix_socket_table: (control_path_name,Unix.file_descr option) Hashtbl.t = Hashtbl.create 1024 -let pidmap: (int,in_pathname * Unix.file_descr) Hashtbl.t = Hashtbl.create 1024 - -let move_gate fname = - let tmpfname=String.concat "." [fname;"tmp"] in - Unix.rename fname tmpfname; - tmpfname - -let move_ungate fname restore = - Unix.rename restore fname - let list_check lst elt _ = let rec list_check_rec lst = match lst with @@ -125,21 +113,12 @@ let mkentry fqp abspath perm uname = (** Close fifos that just got removed *) let closeentry fqp = let control_filename = String.concat "." [fqp;"control"] in - let entry = try Hashtbl.find direct_fifo_table fqp_in with Not_found -> None in + let entry = try Hashtbl.find direct_fifo_table control_filename with Not_found -> None in match entry with | None -> () | Some(_,_,_,fd) -> - close_if_open fd; - Hashtbl.remove direct_fifo_table fqp_in - -let sigchld_handle s = - let pid,_=Unix.waitpid [Unix.WNOHANG] 0 in - try - let fqp_in,fd_out = Hashtbl.find pidmap pid in - begin - reopenentry fqp_in - end - with _ -> () + shutdown fd SHUTDOWN_ALL; + close_if_open fd let rec add_dir_watch fqp = Dirwatcher.add_watch fqp [S_Open] direct_fifo_handler