[glib/glib-2-20] Use inotify_init1 when available



commit 2192f1003f27eaf523917a046a42d8fc0019a87b
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jun 14 22:26:52 2009 -0400

    Use inotify_init1 when available
    
    To avoid leaking the inotify fd. Fixes bug 585478.

 configure.in                 |    1 +
 gio/inotify/inotify-kernel.c |    9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/configure.in b/configure.in
index 7a7ea90..babd07c 100644
--- a/configure.in
+++ b/configure.in
@@ -1535,6 +1535,7 @@ inotify_support=no
 AC_CHECK_HEADERS([sys/inotify.h],
 [
 	inotify_support=yes
+	AC_CHECK_FUNCS(inotify_init1)
 ])
 
 AM_CONDITIONAL(HAVE_INOTIFY, [test "$inotify_support" = "yes"])
diff --git a/gio/inotify/inotify-kernel.c b/gio/inotify/inotify-kernel.c
index f9861a0..b0b85ae 100644
--- a/gio/inotify/inotify-kernel.c
+++ b/gio/inotify/inotify-kernel.c
@@ -187,10 +187,15 @@ gboolean _ik_startup (void (*cb)(ik_event_t *event))
   /* Ignore multi-calls */
   if (initialized) 
     return inotify_instance_fd >= 0;
-  
+
   initialized = TRUE;
+
+#ifdef HAVE_INOTIFY_INIT1
+  inotify_instance_fd = inotify_init1 (IN_CLOEXEC);
+#else
   inotify_instance_fd = inotify_init ();
-  
+#endif
+
   if (inotify_instance_fd < 0)
     return FALSE;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]