[glib] Use inotify_init1 when available
- From: Matthias Clasen <matthiasc src gnome org>
- To: svn-commits-list gnome org
- Subject: [glib] Use inotify_init1 when available
- Date: Sun, 14 Jun 2009 22:29:27 -0400 (EDT)
commit 8a3a3d797e7ef3b66c917c1c0a2ec47300bbf661
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 2275962..540fbd6 100644
--- a/configure.in
+++ b/configure.in
@@ -1599,6 +1599,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]