X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=dirwatcher.ml;h=e96c4e9ee6fc2bbeb9559f15727fdb14bbb7526a;hb=46e48c60e9d524bf71631561e193c443613a2bb5;hp=67a8c9263bba901f46a67f07e8622a404c34bed3;hpb=f37863116494a4011988ad51100e6b956bcb4bd7;p=vsys.git diff --git a/dirwatcher.ml b/dirwatcher.ml index 67a8c92..e96c4e9 100644 --- a/dirwatcher.ml +++ b/dirwatcher.ml @@ -28,11 +28,12 @@ let handle_dir_event dirname evlist str = let add_watch dir events handler = let evcheck = list_check events in - let oneshot = if (evcheck S_Oneshot) then true else false - in let wd = Inotify.add_watch fd dir events in Hashtbl.add masks dir (wd,handler); - Hashtbl.add wdmap wd (dir,Some(handler),oneshot) + Hashtbl.add wdmap wd (dir,Some(handler)) + + (* Ignore the possibility that the whole directory can disappear and come + * back while it is masked *) let mask_watch dir = try @@ -43,7 +44,7 @@ let mask_watch dir = () let unmask_watch dir events = - let _,handler = Hashtbl.find masks dir in + let _,handler = try Hashtbl.find masks dir with Not_found->fprintf logfd "unmask called without mask: %s\n" dir;flush logfd;raise Not_found in try Hashtbl.remove masks dir; add_watch dir events handler @@ -65,16 +66,15 @@ let receive_event (eventdescriptor:fname_and_fd) (bla:fname_and_fd) = List.iter (fun x-> match x with | (wd,evlist,_,Some(str)) -> - let purestr = asciiz(str) in - let (dirname,handler,oneshot) = - try Hashtbl.find wdmap wd with Not_found->("",None,false) - in - if (oneshot) then Hashtbl.remove wdmap wd; - ( - match handler with - | None->fprintf logfd "Unhandled watch descriptor\n";flush logfd - | Some(handler)->handler wd dirname evlist purestr - ) + begin + let purestr = asciiz(str) in + let (dirname,handler) = + try Hashtbl.find wdmap wd with Not_found->("",None) + in + match handler with + | None->fprintf logfd "Unhandled watch descriptor\n";flush logfd + | Some(handler)->handler wd dirname evlist purestr + end | _ -> ()) evs