summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorChengwei Yang <chengwei.yang@intel.com>2013-08-23 16:52:38 +0800
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-08-23 11:53:39 +0100
commit77819311093eb7a7d9a0faa1d54d01db1e72df42 (patch)
tree0794edbae568a4623f5d5ea24b66282851c05614 /bus
parent82600c61dcb715e1651faaa4b5e577fca90bc35d (diff)
downloaddbus-77819311093eb7a7d9a0faa1d54d01db1e72df42.tar.gz
Cleanup: polish inotify backend
At previous, it will do get pid and print a verbose string per inotify event, and then do send signal to the daemon. This patch changes the behavior to get pid and print a verbose string one time. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Diffstat (limited to 'bus')
-rw-r--r--bus/dir-watch-inotify.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c
index d684831d..862c3865 100644
--- a/bus/dir-watch-inotify.c
+++ b/bus/dir-watch-inotify.c
@@ -59,32 +59,30 @@ _handle_inotify_watch (DBusWatch *passed_watch, unsigned int flags, void *data)
char buffer[INOTIFY_BUF_LEN];
ssize_t ret = 0;
int i = 0;
- pid_t pid;
- dbus_bool_t have_change = FALSE;
ret = read (inotify_fd, buffer, INOTIFY_BUF_LEN);
if (ret < 0)
_dbus_verbose ("Error reading inotify event: '%s'\n", _dbus_strerror(errno));
else if (!ret)
_dbus_verbose ("Error reading inotify event: buffer too small\n");
+ else
+ {
+ _dbus_verbose ("Sending SIGHUP signal on reception of %ld inotify event(s)\n", (long) ret);
+ (void) kill (_dbus_getpid(), SIGHUP);
+ }
+#ifdef DBUS_ENABLE_VERBOSE_MODE
while (i < ret)
{
struct inotify_event *ev;
- pid = _dbus_getpid ();
ev = (struct inotify_event *) &buffer[i];
i += INOTIFY_EVENT_SIZE + ev->len;
-#ifdef DBUS_ENABLE_VERBOSE_MODE
if (ev->len)
_dbus_verbose ("event name: '%s'\n", ev->name);
_dbus_verbose ("inotify event: wd=%d mask=%u cookie=%u len=%u\n", ev->wd, ev->mask, ev->cookie, ev->len);
-#endif
- _dbus_verbose ("Sending SIGHUP signal on reception of a inotify event\n");
- have_change = TRUE;
}
- if (have_change)
- (void) kill (pid, SIGHUP);
+#endif
return TRUE;
}