* 1 Bugfix which might have caused vsys to block when reopened several times in succe...
authorSapan Bhatia <sapanb@cs.princeton.edu>
Mon, 30 Jun 2008 14:49:35 +0000 (14:49 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Mon, 30 Jun 2008 14:49:35 +0000 (14:49 +0000)
* Minor tweaks here and there

directfifowatcher.ml
dirwatcher.ml
tests/vsys_conctest.c

index 3dd4b8a..2e1e60a 100644 (file)
@@ -37,7 +37,7 @@ let rec list_check lst elt =
     | [] -> false
     | car::cdr -> if (car==elt) then true else list_check cdr elt
 
-let openentry_safet fifoin =
+let openentry_int fifoin =
   let fdin =
     try openfile fifoin [O_RDONLY;O_NONBLOCK] 0o777 with 
         e->logprint "Error opening and connecting FIFO: %s,%o\n" fifoin 0o777;raise e
@@ -47,8 +47,7 @@ let openentry_safet fifoin =
 (** Open entry safely, by first masking out the file to be opened *)
 let openentry_safe root_dir fqp_in backend_spec =
   Dirwatcher.mask_watch fqp_in;
-  let fd_in = openentry_safet fqp_in in
-    Dirwatcher.unmask_watch fqp_in;
+  let fd_in = openentry_int fqp_in in
     let (fqp,slice_name) = backend_spec in
       Hashtbl.replace direct_fifo_table fqp_in (Some(root_dir,fqp,slice_name,fd_in))
 
@@ -144,10 +143,7 @@ and
   let is_event = list_check evlist in
     if (is_event Open) then 
       let fqp_in = String.concat "/" [dirname;fname] in
-        begin
-          connect_file fqp_in;
-          add_dir_watch dirname
-        end
+          connect_file fqp_in
 
 let del_dir_watch fqp =
   ()
index e06b6fb..810b2bc 100644 (file)
@@ -34,7 +34,6 @@ let add_watch dir events handler =
 
 let mask_watch fqp =
   try 
-    print "Masking %s %d\n" fqp (String.length fqp);
     Hashtbl.replace masks fqp true
   with _ ->
     ()
@@ -74,12 +73,15 @@ let receive_event (eventdescriptor:fname_and_fd) (bla:fname_and_fd) =
                                          let fqp = String.concat "/" [dirname;purestr] in
                                          let mask_filter = Hashtbl.mem masks fqp in
                                            begin
-                                           (*print "Received event for - %s\n"
-                                            * fqp;*)
-                                           if ((not mask_filter) && false) then
-                                                handler wd dirname evlist purestr
+                                           if ((not mask_filter)) then
+                                             begin
+                                                (*logprint "Received event for - %s\n"
+                                                        fqp;*)
+                                                handler wd dirname evlist
+                                                 purestr
+                                             end
                                            else
-                                             print "%s is masked\n" fqp
+                                             unmask_watch fqp
                                            end
                        end
                    | _ -> ()) 
index 33dca3f..1f94c69 100644 (file)
@@ -33,13 +33,10 @@ int main()
       exit(-1);
     }
 
-    printf("Opening...\n");
     if ((fd_in = open(top_in_file, O_WRONLY)) < 0) {
       fprintf(stderr, "error opening %s\n", top_in_file);
       exit(-1);
     }
-    printf("Open.\n");
-
     if ((flag = fcntl(fd_out, F_GETFL)) == -1) {
       printf("fcntl get failed\n");
       exit(-1);
@@ -49,9 +46,7 @@ int main()
            FD_ZERO(&readSet);
            FD_SET(fd_out, &readSet);
 
-    printf("Selecting...\n");
            res = select(fd_out + 1, &readSet, NULL, NULL, NULL);
-    printf("Selected...\n");
            if (res < 0) {
                    if (errno == EINTR || errno == EAGAIN) {
                            printf(".");