diff options
author | Martin Willi <martin@strongswan.org> | 2007-05-08 12:58:33 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2007-05-08 12:58:33 +0000 |
commit | d08b27799a19e5154ee0f81ab0a48c87d2a3397a (patch) | |
tree | 305c466c0f6be1d9c02d559c9294c1e895f53daa /src/charon/bus | |
parent | 6874bf698c537f3184483dd716c3a5b54912718e (diff) | |
download | strongswan-d08b27799a19e5154ee0f81ab0a48c87d2a3397a.tar.bz2 strongswan-d08b27799a19e5154ee0f81ab0a48c87d2a3397a.tar.xz |
properly ignoring signals rised by a thread which is in listening state
Diffstat (limited to 'src/charon/bus')
-rw-r--r-- | src/charon/bus/bus.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/charon/bus/bus.c b/src/charon/bus/bus.c index dfbb8995b..84c93f1d5 100644 --- a/src/charon/bus/bus.c +++ b/src/charon/bus/bus.c @@ -299,7 +299,6 @@ static void vsignal(private_bus_t *this, signal_t signal, level_t level, while (iterator->iterate(iterator, (void**)&listener)) { va_list args_copy; - va_copy(args_copy, args); if (!listener->signal(listener, signal, level, thread, ike_sa, format, args_copy)) @@ -315,15 +314,11 @@ static void vsignal(private_bus_t *this, signal_t signal, level_t level, iterator = this->active_listeners->create_iterator(this->active_listeners, TRUE); while (iterator->iterate(iterator, (void**)&active_listener)) { - /* if the thread raising the signal is the same as the one that - * listens, we skip it. Otherwise we have a deadlock */ - if (active_listener->id == pthread_self()) - { - continue; - } - - /* wait until it is back */ - while (active_listener->state == REGISTERED) + /* wait until all threads are registered. But if the thread raising + * the signal is the same as the one that listens, we skip it. + * Otherwise we would deadlock. */ + while (active_listener->id != pthread_self() && + active_listener->state == REGISTERED) { pthread_cond_wait(&active_listener->cond, &this->mutex); } @@ -346,7 +341,9 @@ static void vsignal(private_bus_t *this, signal_t signal, level_t level, iterator->reset(iterator); while (iterator->iterate(iterator, (void**)&active_listener)) { - while (active_listener->state == REGISTERED) + /* do not wait for ourself, it won't happen (see above) */ + while (active_listener->id != pthread_self() && + active_listener->state == REGISTERED) { pthread_cond_wait(&active_listener->cond, &this->mutex); } |