]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Avoid queueing more than one retry initiate job.
authorTobias Brunner <tobias@strongswan.org>
Fri, 25 May 2012 14:09:31 +0000 (16:09 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 30 May 2012 13:32:52 +0000 (15:32 +0200)
src/libcharon/processing/jobs/retry_initiate_job.c
src/libcharon/sa/ike_sa.c
src/libcharon/sa/ike_sa.h

index 11e573992956af73abe10fec929c224955e445ee..e6da3e3625abb6025f315ab14dfcd1e5d86fe06e 100644 (file)
@@ -54,7 +54,7 @@ METHOD(job_t, execute, void,
        }
        else
        {
-               if (ike_sa->initiate(ike_sa, NULL, 0, NULL, NULL) == DESTROY_ME)
+               if (ike_sa->retry_initiate(ike_sa) == DESTROY_ME)
                {
                        charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager,
                                                                                                                ike_sa);
index 93a8ad8509afbaea6fc6a062d0fb3b225293cfba..c104ff973944e87858ace3dc5592bd2f5cec5c04 100644 (file)
@@ -222,6 +222,11 @@ struct private_ike_sa_t {
         */
        u_int32_t retry_initiate_interval;
 
+       /**
+        * TRUE if a retry_initiate_job has been queued
+        */
+       bool retry_initiate_queued;
+
        /**
         * Timestamps for this IKE_SA
         */
@@ -1162,14 +1167,30 @@ METHOD(ike_sa_t, initiate, status_t,
 
        if (defer_initiate)
        {
-               job_t *job = (job_t*)retry_initiate_job_create(this->ike_sa_id);
-               lib->scheduler->schedule_job(lib->scheduler, (job_t*)job,
-                                                                        this->retry_initiate_interval);
+               if (!this->retry_initiate_queued)
+               {
+                       job_t *job = (job_t*)retry_initiate_job_create(this->ike_sa_id);
+                       lib->scheduler->schedule_job(lib->scheduler, (job_t*)job,
+                                                                                this->retry_initiate_interval);
+                       this->retry_initiate_queued = TRUE;
+               }
                return SUCCESS;
        }
+       this->retry_initiate_queued = FALSE;
        return this->task_manager->initiate(this->task_manager);
 }
 
+METHOD(ike_sa_t, retry_initiate, status_t,
+       private_ike_sa_t *this)
+{
+       if (this->retry_initiate_queued)
+       {
+               this->retry_initiate_queued = FALSE;
+               return initiate(this, NULL, 0, NULL, NULL);
+       }
+       return SUCCESS;
+}
+
 METHOD(ike_sa_t, process_message, status_t,
        private_ike_sa_t *this, message_t *message)
 {
@@ -2089,6 +2110,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id, bool initiator,
                        .set_statistic = _set_statistic,
                        .process_message = _process_message,
                        .initiate = _initiate,
+                       .retry_initiate = _retry_initiate,
                        .get_ike_cfg = _get_ike_cfg,
                        .set_ike_cfg = _set_ike_cfg,
                        .get_peer_cfg = _get_peer_cfg,
index a3c3de81ccbd1901537983202505adee20db00d8..5b2eb4ed1ca4fea6dc776a789fcebc811e6ca831 100644 (file)
@@ -694,6 +694,15 @@ struct ike_sa_t {
                                                  u_int32_t reqid, traffic_selector_t *tsi,
                                                  traffic_selector_t *tsr);
 
+       /**
+        * Retry initiation of this IKE_SA after it got deferred previously.
+        *
+        * @return
+        *                                              - SUCCESS if initiation deferred or started
+        *                                              - DESTROY_ME if initiation failed
+        */
+       status_t (*retry_initiate) (ike_sa_t *this);
+
        /**
         * Initiates the deletion of an IKE_SA.
         *