From: Tobias Brunner Date: Thu, 7 Sep 2017 07:51:49 +0000 (+0200) Subject: watcher: Don't notify watcher if removed FD was not found X-Git-Tag: 5.6.1rc1~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0d08959a040708c74f1302d5af4c2ddabd328324;p=thirdparty%2Fstrongswan.git watcher: Don't notify watcher if removed FD was not found This can happen if a stream is used blocking exclusively (the FD is never registered with watcher, but is removed in the stream's destructor just in case it ever was - doing this conditionally would require an additional flag in streams). There may be no thread reading from the read end of the notify pipe (e.g. in starter), causing the write to the notify pipe to block after it's full. Anyway, doing a relatively expensive FD update is unnecessary if there were no changes. Fixes #1453. --- diff --git a/src/libstrongswan/processing/watcher.c b/src/libstrongswan/processing/watcher.c index df6066b193..4466e91eb1 100644 --- a/src/libstrongswan/processing/watcher.c +++ b/src/libstrongswan/processing/watcher.c @@ -513,6 +513,7 @@ METHOD(watcher_t, remove_, void, private_watcher_t *this, int fd) { entry_t *entry, *prev = NULL; + bool found = FALSE; this->mutex->lock(this->mutex); while (TRUE) @@ -530,6 +531,7 @@ METHOD(watcher_t, remove_, void, break; } entry = remove_entry(this, entry, prev); + found = TRUE; continue; } prev = entry; @@ -541,8 +543,10 @@ METHOD(watcher_t, remove_, void, } this->condvar->wait(this->condvar, this->mutex); } - - update(this); + if (found) + { + update(this); + } this->mutex->unlock(this->mutex); }