let close_if_open fd = (try (ignore(close fd);) with _ -> ())
-
let direct_fifo_table: (string,(string*string*string*Unix.file_descr) option) Hashtbl.t = Hashtbl.create 1024
-let pidmap: (int,string) Hashtbl.t = Hashtbl.create 1024
+let pidmap: (int,string*Unix.file_descr) Hashtbl.t = Hashtbl.create 1024
let rec list_check lst elt =
match lst with
(** Open fifos for a session. SHOULD NOt shutdown vsys if the fifos don't exist *)
-let openentry_in root_dir fqp_in backend_spec =
- Dirwatcher.mask_watch root_dir;
+let openentry_in rp root_dir fqp_in backend_spec =
+ match rp with
+ |
+ |
+ Dirwatcher.mask_watch root_dir fqp_in;
let fd_in = openentry_int fqp_in in
- Dirwatcher.unmask_watch root_dir [S_Open];
+ Dirwatcher.unmask_watch root_dir fqp_in;
let (fqp,slice_name) = backend_spec in
Hashtbl.replace direct_fifo_table fqp_in (Some(root_dir,fqp,slice_name,fd_in))
Hashtbl.find direct_fifo_table fqp_in with _ -> None in
match entry_info with
| Some(_,execpath,slice_name,fifo_fdin) ->
- fprintf logfd "Executing %s for slice %s\n" execpath slice_name;flush logfd;
+ (*fprintf logfd "Executing %s for slice %s\n" execpath
+ * slice_name;flush logfd;*)
begin
let len = String.length fqp_in in
let fqp = String.sub fqp_in 0 (len-3) in
clear_nonblock fifo_fdin;
let pid=try Some(create_process execpath [|execpath;slice_name|] fifo_fdin fifo_fdout fifo_fdout) with e -> None in
match pid with
- | Some(pid) ->Hashtbl.add pidmap pid fqp_in
+ | Some(pid) ->
+ if (fifo_fdout <> stdout) then close_if_open fifo_fdout;
+ Hashtbl.add pidmap pid (fqp_in,fifo_fdout)
| None ->fprintf logfd "Error executing service: %s\n" execpath;flush logfd;reopenentry fqp_in
);
ignore(sigprocmask SIG_UNBLOCK [Sys.sigchld]);
let sigchld_handle s =
let pid,_=Unix.waitpid [Unix.WNOHANG] 0 in
try
- let fqp_in = Hashtbl.find pidmap pid in
+ let fqp_in,fd_out = Hashtbl.find pidmap pid in
+ begin
reopenentry fqp_in
+ end
+
with _ -> ()
let rec add_dir_watch fqp =