From f513c549e6e0b259e176013649828ca5764c1d80 Mon Sep 17 00:00:00 2001 From: Joe Marcus Clarke Date: Sun, 3 Jul 2005 06:11:00 +0000 Subject: [PATCH] Remove the kqueue watch from the mainloop before unref'ing it. This eliminates one needless kevent system call. --- devel/dbus/Makefile | 2 +- devel/dbus/files/patch-bus_dir-watch.c | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/devel/dbus/Makefile b/devel/dbus/Makefile index 100433763e9f..90d4c4933182 100644 --- a/devel/dbus/Makefile +++ b/devel/dbus/Makefile @@ -7,7 +7,7 @@ PORTNAME= dbus PORTVERSION= 0.34 -PORTREVISION?= 2 +PORTREVISION?= 3 CATEGORIES?= devel gnome MASTER_SITES= http://dbus.freedesktop.org/releases/ diff --git a/devel/dbus/files/patch-bus_dir-watch.c b/devel/dbus/files/patch-bus_dir-watch.c index 0673a8caa8f3..2eb1dfa1a882 100644 --- a/devel/dbus/files/patch-bus_dir-watch.c +++ b/devel/dbus/files/patch-bus_dir-watch.c @@ -1,5 +1,5 @@ --- bus/dir-watch.c.orig Tue Jun 14 22:31:38 2005 -+++ bus/dir-watch.c Sun Jul 3 01:40:21 2005 ++++ bus/dir-watch.c Sun Jul 3 02:07:14 2005 @@ -28,17 +28,25 @@ #include #include @@ -28,7 +28,7 @@ /* use a static array to avoid handling OOM */ static int fds[MAX_DIRS_TO_WATCH]; static int num_fds = 0; -@@ -92,6 +100,141 @@ bus_drop_all_directory_watches (void) +@@ -92,6 +100,144 @@ bus_drop_all_directory_watches (void) } } @@ -41,6 +41,13 @@ +static int fds[MAX_DIRS_TO_WATCH]; +static int num_fds = 0; +static DBusWatch *watch = NULL; ++static DBusLoop *loop = NULL; ++ ++static dbus_bool_t ++_kqueue_watch_callback (DBusWatch *watch, unsigned int condition, void *data) ++{ ++ return dbus_watch_handle (watch, condition); ++} + +static dbus_bool_t +_handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data) @@ -63,7 +70,9 @@ + kq = -1; + if (watch != NULL) + { ++ _dbus_loop_remove_watch (loop, watch, _kqueue_watch_callback, NULL); + _dbus_watch_unref (watch); ++ watch = NULL; + } + pid = getpid (); + _dbus_verbose ("Sending SIGHUP signal since kqueue has been closed\n"); @@ -73,12 +82,6 @@ + return TRUE; +} + -+static dbus_bool_t -+_kqueue_watch_callback (DBusWatch *watch, unsigned int condition, void *data) -+{ -+ return dbus_watch_handle (watch, condition); -+} -+ +void +bus_watch_directory (const char *dir, void *userdata) +{ @@ -89,7 +92,6 @@ + + if (kq < 0) + { -+ DBusLoop *loop; + + kq = kqueue (); + if (kq < 0) @@ -118,6 +120,7 @@ + close (kq); + kq = -1; + _dbus_watch_unref (watch); ++ watch = NULL; + goto out; + } + }