diff options
author | Martin Willi <martin@revosec.ch> | 2014-03-10 10:48:27 +0100 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2014-05-07 14:13:34 +0200 |
commit | d2b07d3187c38327cf949345d6255706d3477645 (patch) | |
tree | 9ce779e2064d718eaede1ca498f86b0827b253ae /src/libstrongswan/processing/watcher.c | |
parent | d16d5a245f0b313bed187462e8b06dd9391e2982 (diff) | |
download | strongswan-d2b07d3187c38327cf949345d6255706d3477645.tar.bz2 strongswan-d2b07d3187c38327cf949345d6255706d3477645.tar.xz |
watcher: Don't wait for running callback once watcher thread cancelled
During shutdown, waiting for callbacks might never complete, as queued
callbacks might not get executed under certain conditions. Not the clean fix,
but works good enough for now.
Seen on Windows in vici tests.
Diffstat (limited to 'src/libstrongswan/processing/watcher.c')
-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 a0b5529b3..09905646c 100644 --- a/src/libstrongswan/processing/watcher.c +++ b/src/libstrongswan/processing/watcher.c @@ -50,6 +50,11 @@ struct private_watcher_t { bool pending; /** + * Is watcher running? + */ + bool running; + + /** * Lock to access FD list */ mutex_t *mutex; @@ -225,6 +230,7 @@ static void activate_all(private_watcher_t *this) entry->in_callback = 0; } enumerator->destroy(enumerator); + this->running = FALSE; this->condvar->broadcast(this->condvar); this->mutex->unlock(this->mutex); } @@ -373,6 +379,7 @@ METHOD(watcher_t, add, void, this->fds->insert_last(this->fds, entry); if (this->fds->get_count(this->fds) == 1) { + this->running = TRUE; lib->processor->queue_job(lib->processor, (job_t*)callback_job_create_with_prio((void*)watch, this, NULL, (callback_job_cancel_t)return_false, JOB_PRIO_CRITICAL)); @@ -400,7 +407,7 @@ METHOD(watcher_t, remove_, void, { if (entry->fd == fd) { - if (entry->in_callback) + if (this->running && entry->in_callback) { is_in_callback = TRUE; break; |