From f5aeba0f02a9540461258dcca82e020f687ebb72 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 12 Jun 2026 13:08:00 +0200 Subject: [PATCH] watcher: Remove unnecessary pending flag This was added with 5ce3c9b15a57 ("watcher: Rebuild fdset when select() fails"), i.e. before switching to poll(), solely to suppress errors when FDs are closed and select() would return with an error. With poll() this should not happen result in an error (it potentially indicates this via POLLNVAL in revents of that FD in the array). Because the flag was not consistently changed/read with the mutex held, some analysis tools got confused and imagined wild deadlock scenarios. --- src/libstrongswan/processing/watcher.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/libstrongswan/processing/watcher.c b/src/libstrongswan/processing/watcher.c index e0b547d8a..fd1c2354c 100644 --- a/src/libstrongswan/processing/watcher.c +++ b/src/libstrongswan/processing/watcher.c @@ -56,11 +56,6 @@ struct private_watcher_t { */ u_int count; - /** - * Pending update of FD list? - */ - bool pending; - /** * Running state of watcher */ @@ -177,7 +172,6 @@ static void update_and_unlock(private_watcher_t *this) char buf[1] = { 'u' }; int error = 0; - this->pending = TRUE; if (this->notify[1] != -1) { if (write(this->notify[1], buf, sizeof(buf)) == -1) @@ -461,7 +455,6 @@ static job_requeue_t watch(private_watcher_t *this) break; } } - this->pending = FALSE; DBG2(DBG_WCH, "watcher got notification, rebuilding"); break; } @@ -521,12 +514,10 @@ static job_requeue_t watch(private_watcher_t *this) break; } } - else + else if (errno != EINTR) { - if (!this->pending && errno != EINTR) - { /* complain only if no pending updates */ - DBG1(DBG_WCH, "watcher poll() error: %s", strerror(errno)); - } + /* rebuild FDSET on errors, just retry if interrupted */ + DBG1(DBG_WCH, "watcher poll() error: %s", strerror(errno)); break; } }