diff options
author | Martin Willi <martin@revosec.ch> | 2013-10-24 15:07:43 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2013-10-24 15:37:20 +0200 |
commit | 5ce3c9b15a5754498340abc6589f98629a995776 (patch) | |
tree | 1d1984a099720fbf226cbec1ef2f436fe589d6c4 | |
parent | 1a20a22d0985120ada7a9010b51bd91b8d98a06d (diff) | |
download | strongswan-5ce3c9b15a5754498340abc6589f98629a995776.tar.bz2 strongswan-5ce3c9b15a5754498340abc6589f98629a995776.tar.xz |
watcher: Rebuild fdset when select() fails
This should make sure we refresh the fdset if a user closes an FD it just
removed. Some selects() seem to complain about the bad FD before signaling the
notification pipe.
-rw-r--r-- | src/libstrongswan/processing/watcher.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libstrongswan/processing/watcher.c b/src/libstrongswan/processing/watcher.c index 3009be608..9773e7601 100644 --- a/src/libstrongswan/processing/watcher.c +++ b/src/libstrongswan/processing/watcher.c @@ -45,6 +45,11 @@ struct private_watcher_t { linked_list_t *fds; /** + * Pending update of FD list? + */ + bool pending; + + /** * Lock to access FD list */ mutex_t *mutex; @@ -106,6 +111,7 @@ static void update(private_watcher_t *this) { char buf[1] = { 'u' }; + this->pending = TRUE; if (this->notify[1] != -1) { ignore_result(write(this->notify[1], buf, sizeof(buf))); @@ -294,6 +300,7 @@ static job_requeue_t watch(private_watcher_t *this) { DBG2(DBG_JOB, "watcher got notification, rebuilding"); while (read(this->notify[0], buf, sizeof(buf)) > 0); + this->pending = FALSE; return JOB_REQUEUE_DIRECT; } @@ -333,7 +340,11 @@ static job_requeue_t watch(private_watcher_t *this) } else { - DBG1(DBG_JOB, "watcher select() error: %s", strerror(errno)); + if (!this->pending) + { /* complain only if no pending updates */ + DBG1(DBG_JOB, "watcher select() error: %s", strerror(errno)); + } + return JOB_REQUEUE_DIRECT; } } } |