From ff3dc8fefe953fd3650279e064bf63b212c5699a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 13 Mar 2019 17:36:18 +0000 Subject: filemon: ensure watch IDs are unique to QFileMonitor scope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The watch IDs are mistakenly only unique within the scope of the directory being monitored. This is not useful for clients which are monitoring multiple directories. They require watch IDs to be unique globally within the QFileMonitor scope. Reviewed-by: Marc-André Lureau Tested-by: Bandan Das Reviewed-by: Bandan Das Signed-off-by: Daniel P. Berrangé --- util/filemonitor-inotify.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'util') diff --git a/util/filemonitor-inotify.c b/util/filemonitor-inotify.c index 3a72be037f..3eb29f860b 100644 --- a/util/filemonitor-inotify.c +++ b/util/filemonitor-inotify.c @@ -29,7 +29,7 @@ struct QFileMonitor { int fd; - + int nextid; /* watch ID counter */ QemuMutex lock; /* protects dirs & idmap */ GHashTable *dirs; /* dirname => QFileMonitorDir */ GHashTable *idmap; /* inotify ID => dirname */ @@ -47,7 +47,6 @@ typedef struct { typedef struct { char *path; int id; /* inotify ID */ - int nextid; /* watch ID counter */ GArray *watches; /* QFileMonitorWatch elements */ } QFileMonitorDir; @@ -277,7 +276,7 @@ qemu_file_monitor_add_watch(QFileMonitor *mon, } } - watch.id = dir->nextid++; + watch.id = mon->nextid++; watch.filename = g_strdup(filename); watch.cb = cb; watch.opaque = opaque; -- cgit v1.2.3