Set thread specific SA on bus for each enumerated IKE_SA
authorMartin Willi <martin@revosec.ch>
Fri, 20 Jan 2012 11:21:13 +0000 (12:21 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:31:38 +0000 (17:31 +0100)
src/libcharon/sa/ike_sa_manager.c

index 24e1388..b617a13 100644 (file)
@@ -1269,6 +1269,7 @@ static bool enumerator_filter_wait(private_ike_sa_manager_t *this,
        if (wait_for_entry(this, *in, *segment))
        {
                *out = (*in)->ike_sa;
+               charon->bus->set_sa(charon->bus, *out);
                return TRUE;
        }
        return FALSE;
@@ -1285,17 +1286,26 @@ static bool enumerator_filter_skip(private_ike_sa_manager_t *this,
                !(*in)->checked_out)
        {
                *out = (*in)->ike_sa;
+               charon->bus->set_sa(charon->bus, *out);
                return TRUE;
        }
        return FALSE;
 }
 
+/**
+ * Reset threads SA after enumeration
+ */
+static void reset_sa(void *data)
+{
+       charon->bus->set_sa(charon->bus, NULL);
+}
+
 METHOD(ike_sa_manager_t, create_enumerator, enumerator_t*,
        private_ike_sa_manager_t* this, bool wait)
 {
        return enumerator_create_filter(create_table_enumerator(this),
                        wait ? (void*)enumerator_filter_wait : (void*)enumerator_filter_skip,
-                       this, NULL);
+                       this, reset_sa);
 }
 
 METHOD(ike_sa_manager_t, checkin, void,