From b8b329f72fa44685bbd522cb5312dd19d352f580 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Mon, 23 Mar 2009 20:44:08 +0000 Subject: [PATCH] contd... --- .dep | 12 ++++++------ frontend.ml | 25 +++++++++++++++++++------ unixsocketwatcher.ml | 31 +++++-------------------------- 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/.dep b/.dep index 60ed53b..cfa40da 100644 --- a/.dep +++ b/.dep @@ -14,9 +14,9 @@ fifowatcher.cmo: splice.cmo inotify.cmi globals.cmo fdwatcher.cmo \ dirwatcher.cmo fifowatcher.cmx: splice.cmx inotify.cmi globals.cmx fdwatcher.cmx \ dirwatcher.cmx -frontend.cmo: globals.cmo directfifowatcher.cmo -frontend.cmx: globals.cmx directfifowatcher.cmx -main.cmo: inotify.cmi globals.cmo frontend.cmo fifowatcher.cmo fdwatcher.cmo \ - dirwatcher.cmo conffile.cmo backend.cmo -main.cmx: inotify.cmi globals.cmx frontend.cmx fifowatcher.cmx fdwatcher.cmx \ - dirwatcher.cmx conffile.cmx backend.cmx +frontend.cmo: unixsocketwatcher.cmo globals.cmo directfifowatcher.cmo +frontend.cmx: unixsocketwatcher.cmx globals.cmx directfifowatcher.cmx +main.cmo: inotify.cmi globals.cmo frontend.cmo fdwatcher.cmo dirwatcher.cmo \ + directfifowatcher.cmo conffile.cmo backend.cmo +main.cmx: inotify.cmi globals.cmx frontend.cmx fdwatcher.cmx dirwatcher.cmx \ + directfifowatcher.cmx conffile.cmx backend.cmx diff --git a/frontend.ml b/frontend.ml index 9d444c3..cff3c64 100644 --- a/frontend.ml +++ b/frontend.ml @@ -77,12 +77,25 @@ object(this) let fqp = String.concat "/" [root_dir;rel] in let fqp_in = String.concat "." [fqp;"in"] in let fqp_out = String.concat "." [fqp;"out"] in - Directfifowatcher.closeentry fqp; - try - Unix.unlink fqp_in; - Unix.unlink fqp_out - with _ -> - logprint "Hm. %s disappeared. Looks like slice %s shot itself in the foot\n" fqp (this#get_slice_name ()) + let fqp_control = String.concat "." [fqp;"out"] in + + if (this#is_fd_passer rel) then + begin + Unixsocketwatcher.closeentry fqp; + try + Unix.unlink fqp_control + with _ -> + logprint "Hm. %s disappeared. Looks like slice %s shot itself in the foot\n" fqp (this#get_slice_name ()) + end + else + begin + Directfifowatcher.closeentry fqp; + try + Unix.unlink fqp_in; + Unix.unlink fqp_out + with _ -> + logprint "Hm. %s disappeared. Looks like slice %s shot itself in the foot\n" fqp (this#get_slice_name ()) + end method rmdir rp = match rp with Relpath(rel) -> 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 -- 2.43.0