vici: Properly skip raise_event() for unknown event names
authorMartin Willi <martin@revosec.ch>
Thu, 1 May 2014 08:26:49 +0000 (10:26 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 7 May 2014 12:13:38 +0000 (14:13 +0200)
src/libcharon/plugins/vici/vici_dispatcher.c

index 4fd8028..0df867a 100644 (file)
@@ -437,23 +437,23 @@ METHOD(vici_dispatcher_t, raise_event, void,
        if (event)
        {
                event->uses++;
        if (event)
        {
                event->uses++;
-       }
-       this->mutex->unlock(this->mutex);
+               this->mutex->unlock(this->mutex);
 
 
-       enumerator = array_create_enumerator(event->clients);
-       while (enumerator->enumerate(enumerator, &current))
-       {
-               if (id == 0 || id == *current)
+               enumerator = array_create_enumerator(event->clients);
+               while (enumerator->enumerate(enumerator, &current))
                {
                {
-                       send_op(this, *current, VICI_EVENT, name, message);
+                       if (id == 0 || id == *current)
+                       {
+                               send_op(this, *current, VICI_EVENT, name, message);
+                       }
                }
                }
-       }
-       enumerator->destroy(enumerator);
+               enumerator->destroy(enumerator);
 
 
-       this->mutex->lock(this->mutex);
-       if (--event->uses == 0)
-       {
-               this->cond->broadcast(this->cond);
+               this->mutex->lock(this->mutex);
+               if (--event->uses == 0)
+               {
+                       this->cond->broadcast(this->cond);
+               }
        }
        this->mutex->unlock(this->mutex);
 
        }
        this->mutex->unlock(this->mutex);