aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-07-18 11:05:01 +0000
committerMartin Willi <martin@strongswan.org>2008-07-18 11:05:01 +0000
commita98793adfe9ba356e416f3804cc1f22f83515789 (patch)
treebec8523838e1b8afbf808e0f2d8055d1c5100037 /src
parent1082b061218d13e5811d79a48f88b30aff25005a (diff)
downloadstrongswan-a98793adfe9ba356e416f3804cc1f22f83515789.tar.bz2
strongswan-a98793adfe9ba356e416f3804cc1f22f83515789.tar.xz
allow but filter recursive listener invocation
Diffstat (limited to 'src')
-rw-r--r--src/charon/bus/bus.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/charon/bus/bus.c b/src/charon/bus/bus.c
index 1c57fcc40..c5c79e95e 100644
--- a/src/charon/bus/bus.c
+++ b/src/charon/bus/bus.c
@@ -101,6 +101,11 @@ struct entry_t {
bool blocker;
/**
+ * are we currently calling this listener
+ */
+ bool calling;
+
+ /**
* condvar where active listeners wait
*/
condvar_t *condvar;
@@ -115,6 +120,7 @@ static entry_t *entry_create(bus_listener_t *listener, bool blocker)
this->listener = listener;
this->blocker = blocker;
+ this->calling = FALSE;
this->condvar = condvar_create(CONDVAR_DEFAULT);
return this;
@@ -276,6 +282,11 @@ typedef struct {
*/
static bool signal_cb(entry_t *entry, signal_data_t *data)
{
+ if (entry->calling)
+ { /* avoid recursive calls */
+ return FALSE;
+ }
+ entry->calling = TRUE;
if (!entry->listener->signal(entry->listener, data->signal, data->level,
data->thread, data->ike_sa, data->format, data->args))
{
@@ -288,8 +299,10 @@ static bool signal_cb(entry_t *entry, signal_data_t *data)
{
entry_destroy(entry);
}
+ entry->calling = FALSE;
return TRUE;
}
+ entry->calling = FALSE;
return FALSE;
}
@@ -355,7 +368,7 @@ bus_t *bus_create()
this->public.destroy = (void(*)(bus_t*)) destroy;
this->listeners = linked_list_create();
- this->mutex = mutex_create(MUTEX_DEFAULT);
+ this->mutex = mutex_create(MUTEX_RECURSIVE);
pthread_key_create(&this->thread_id, NULL);
pthread_key_create(&this->thread_sa, NULL);