[prev in list] [next in list] [prev in thread] [next in thread]
List: freedesktop-dbus
Subject: Patch: inotify monitor being too agressive
From: Frederic Crozat <fcrozat () mandriva ! com>
Date: 2008-03-27 9:40:44
Message-ID: 1206610844.24525.97.camel () trinidad ! mandrakesoft ! com
[Download RAW message or body]
Hi,
I've got bug report on dbus not seeing new configuration files (while
inotify monitoring should work fine).
After some investigation, I noticed inotify monitoring is a little too
good : when file are created by package manager, IN_CREATE event might
be fired before file is finished writing on disk : in this case, dbus
will discard the file (since it is not valid XML) and will not put back
a monitor on configuration directory.
Attached patch fixes this behavior by monitoring only IN_CLOSE_WRITE,
IN_DELETE, IN_MOVE_TO and IN_MOVE_FROM events. This way, only atomic
changes to configuration file are monitored.
It also fixes a build error when enabling verbose mode.
--
Frederic Crozat <fcrozat@mandriva.com>
Mandriva
["dbus-1.1.20-fixmonitor.patch" (dbus-1.1.20-fixmonitor.patch)]
diff -p -up dbus-1.1.20/bus/dir-watch-inotify.c.fixmonitor dbus-1.1.20/bus/dir-watch-inotify.c
--- dbus-1.1.20/bus/dir-watch-inotify.c.fixmonitor 2008-03-27 10:02:23.000000000 +0100
+++ dbus-1.1.20/bus/dir-watch-inotify.c 2008-03-27 10:18:07.000000000 +0100
@@ -64,7 +64,7 @@ _handle_inotify_watch (DBusWatch *watch,
ret = read (inotify_fd, buffer, INOTIFY_BUF_LEN);
if (ret < 0)
- _dbus_verbose ("Error reading inotify event: '%s'\n, _dbus_strerror(errno)");
+ _dbus_verbose ("Error reading inotify event: '%s'\n", _dbus_strerror(errno));
else if (!ret)
_dbus_verbose ("Error reading inotify event: buffer too small\n");
@@ -134,7 +134,7 @@ bus_watch_directory (const char *dir, Bu
goto out;
}
- wd = inotify_add_watch (inotify_fd, dir, IN_MODIFY | IN_CREATE | IN_DELETE);
+ wd = inotify_add_watch (inotify_fd, dir, IN_CLOSE_WRITE | IN_DELETE | IN_MOVED_TO | IN_MOVED_FROM);
if (wd < 0)
{
_dbus_warn ("Cannot setup inotify for '%s'; error '%s'\n", dir, _dbus_strerror (errno));
@@ -156,7 +156,7 @@ bus_drop_all_directory_watches (void)
_dbus_verbose ("Dropping all watches on config directories\n");
ret = close (inotify_fd);
if (ret)
- _dbus_verbose ("Error dropping watches: '%s'\n", perror(ret));
+ _dbus_verbose ("Error dropping watches: '%s'\n", _dbus_strerror(errno));
num_wds = 0;
inotify_fd = -1;
_______________________________________________
dbus mailing list
dbus@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dbus
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic