From 70c4e7d774299920bd1730d9762afe75495bd3b9 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Wed, 12 Feb 2025 18:01:35 +0100 Subject: [PATCH] iwatch: ensure adding a new watcher is idempotent Some subsystems call iwatch_add() without first calling iwatch_del() on the same path. E.g., cgroup_config(). Issue #417 but unclear atm. if this is the root cause. Signed-off-by: Joachim Wiberg --- src/iwatch.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/iwatch.c b/src/iwatch.c index 0c56534e..4e742066 100644 --- a/src/iwatch.c +++ b/src/iwatch.c @@ -96,6 +96,12 @@ int iwatch_add1(struct iwatch *iw, char *file, uint32_t mask) if (!initialized) return -1; + iwp = iwatch_find_by_path(iw, file); + if (iwp) { + dbg("skipping, %s already registered", file); + return 0; + } + if (!fexist(file)) { dbg("skipping %s: no such file or directory", file); return 0;