aboutsummaryrefslogtreecommitdiff
path: root/util/filemonitor-inotify.c
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2019-03-13 17:36:18 +0000
committerDaniel P. Berrangé <berrange@redhat.com>2019-04-02 13:46:33 +0100
commitff3dc8fefe953fd3650279e064bf63b212c5699a (patch)
tree8d3161206551075e2f0d5f864158913a9e292f68 /util/filemonitor-inotify.c
parentb26c3f9cbd784a5f7db68049fd9c49a0a2077734 (diff)
filemon: ensure watch IDs are unique to QFileMonitor scope
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 <marcandre.lureau@redhat.com> Tested-by: Bandan Das <bsd@redhat.com> Reviewed-by: Bandan Das <bsd@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'util/filemonitor-inotify.c')
-rw-r--r--util/filemonitor-inotify.c5
1 files changed, 2 insertions, 3 deletions
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;