]> rtime.felk.cvut.cz Git - sojka/libev.git/commitdiff
inotify should not keep a reference
authorMarc Alexander Lehmann <libev@schmorp.de>
Sat, 14 Nov 2009 00:15:21 +0000 (00:15 +0000)
committerMarc Alexander Lehmann <libev@schmorp.de>
Sat, 14 Nov 2009 00:15:21 +0000 (00:15 +0000)
Changes
ev.c

diff --git a/Changes b/Changes
index 807e32c5f3388bf7e45309d7501a9d4d4264cf25..5780800465cd66818e9043d55415990c5b9bd035 100644 (file)
--- a/Changes
+++ b/Changes
@@ -3,6 +3,9 @@ Revision history for libev, a high-performance and full-featured event loop.
 TODO: somehow unblock procmask?
        - backport inotify code to C89.
         - inotify file descriptors could leak into child processes.
+        - inotify usage would keep an errornous extra ref on the loop,
+          preventing exit when unregistering all watchers (testcase
+          provided by ry@tinyclouds.org).
         - implement EV_WIN32_HANDLE_TO_FD and EV_WIN32_CLOSE_FD configuration
           symbols to make it easier for apps to do their own fd management.
         - support EV_IDLE_ENABLE being disabled in ev++.h
@@ -10,6 +13,8 @@ TODO: somehow unblock procmask?
         - point out the unspecified signal mask in the documentation.
         - take advantage of inotify_init1, if available, to set cloexec/nonblock
           on fd creation, to avoid races.
+        - the signal handling pipe wasn't always initialised under windows
+          (analysed by lekma).
         - changed minimum glibc requirement from glibc 2.9 to 2.7, for
           signalfd.
 
diff --git a/ev.c b/ev.c
index 0ba0da5b78919aea60d7c5250db85628c02c3957..a50aee4f511b51528b86de11a0d63e8fc59cc7df 100644 (file)
--- a/ev.c
+++ b/ev.c
@@ -1660,12 +1660,7 @@ loop_destroy (EV_P)
 
 #if EV_USE_SIGNALFD
   if (ev_is_active (&sigfd_w))
-    {
-      /*ev_ref (EV_A);*/
-      /*ev_io_stop (EV_A_ &sigfd_w);*/
-
-      close (sigfd);
-    }
+    close (sigfd);
 #endif
 
 #if EV_USE_INOTIFY
@@ -2754,6 +2749,8 @@ ev_signal_start (EV_P_ ev_signal *w)
 # endif
       {
 # if _WIN32
+        evpipe_init (EV_A);
+
         signal (w->signum, ev_sighandler);
 # else
         struct sigaction sa;
@@ -2898,7 +2895,7 @@ infy_add (EV_P_ ev_stat *w)
       wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w);
 
       /* now local changes will be tracked by inotify, but remote changes won't */
-      /* unless the filesystem it known to be local, we therefore still poll */
+      /* unless the filesystem is known to be local, we therefore still poll */
       /* also do poll on <2.6.25, but with normal frequency */
 
       if (fs_2625 && !statfs (w->path, &sfs))
@@ -3027,6 +3024,7 @@ infy_init (EV_P)
       ev_io_init (&fs_w, infy_cb, fs_fd, EV_READ);
       ev_set_priority (&fs_w, EV_MAXPRI);
       ev_io_start (EV_A_ &fs_w);
+      ev_unref (EV_A);
     }
 }
 
@@ -3038,6 +3036,7 @@ infy_fork (EV_P)
   if (fs_fd < 0)
     return;
 
+  ev_ref (EV_A);
   ev_io_stop (EV_A_ &fs_w);
   close (fs_fd);
   fs_fd = infy_newfd ();
@@ -3047,6 +3046,7 @@ infy_fork (EV_P)
       fd_intern (fs_fd);
       ev_io_set (&fs_w, fs_fd, EV_READ);
       ev_io_start (EV_A_ &fs_w);
+      ev_unref (EV_A);
     }
 
   for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot)