mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
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>
This commit is contained in:
parent
b26c3f9cbd
commit
ff3dc8fefe
2 changed files with 110 additions and 11 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue