diff options
| author | Martin Willi <martin@revosec.ch> | 2014-02-18 17:54:34 +0100 |
|---|---|---|
| committer | Martin Willi <martin@revosec.ch> | 2014-05-07 14:13:34 +0200 |
| commit | d16d5a245f0b313bed187462e8b06dd9391e2982 (patch) | |
| tree | 07ff3562ff3589dd164c27f13878cff0f60d298d /src/libstrongswan/processing | |
| parent | 874e212f71b86a483445036096b29f0dd81b3ed3 (diff) | |
| download | strongswan-d16d5a245f0b313bed187462e8b06dd9391e2982.tar.bz2 strongswan-d16d5a245f0b313bed187462e8b06dd9391e2982.tar.xz | |
watcher: Avoid queueing multiple watcher callbacks at the same time
While we don't add FDs with an active callback to the watched FDSET, we still
can get notifications for callbacks active due the asynchronous processing
of the same.
To avoid queue multiple callbacks, we check for queued callbacks before
activating new ones.
Diffstat (limited to 'src/libstrongswan/processing')
| -rw-r--r-- | src/libstrongswan/processing/watcher.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libstrongswan/processing/watcher.c b/src/libstrongswan/processing/watcher.c index cc3c3a788..a0b5529b3 100644 --- a/src/libstrongswan/processing/watcher.c +++ b/src/libstrongswan/processing/watcher.c @@ -238,6 +238,7 @@ static job_requeue_t watch(private_watcher_t *this) entry_t *entry; fd_set rd, wr, ex; int maxfd = 0, res; + bool rebuild = FALSE; FD_ZERO(&rd); FD_ZERO(&wr); @@ -282,7 +283,7 @@ static job_requeue_t watch(private_watcher_t *this) enumerator->destroy(enumerator); this->mutex->unlock(this->mutex); - while (TRUE) + while (!rebuild) { char buf[1]; bool old; @@ -308,6 +309,11 @@ static job_requeue_t watch(private_watcher_t *this) enumerator = this->fds->create_enumerator(this->fds); while (enumerator->enumerate(enumerator, &entry)) { + if (entry->in_callback) + { + rebuild = TRUE; + break; + } if (FD_ISSET(entry->fd, &rd) && (entry->events & WATCHER_READ)) { DBG2(DBG_JOB, "watched FD %d ready to read", entry->fd); @@ -347,6 +353,7 @@ static job_requeue_t watch(private_watcher_t *this) return JOB_REQUEUE_DIRECT; } } + return JOB_REQUEUE_DIRECT; } METHOD(watcher_t, add, void, |
