Trigger DPD not before IKE_SA state gets updated
authorMartin Willi <martin@revosec.ch>
Thu, 2 Feb 2012 09:33:40 +0000 (10:33 +0100)
committerMartin Willi <martin@revosec.ch>
Thu, 2 Feb 2012 09:35:50 +0000 (10:35 +0100)
src/libcharon/sa/ike_sa.c

index 34b81a9..0d8f38f 100644 (file)
@@ -619,6 +619,8 @@ METHOD(ike_sa_t, get_state, ike_sa_state_t,
 METHOD(ike_sa_t, set_state, void,
        private_ike_sa_t *this, ike_sa_state_t state)
 {
+       bool trigger_dpd = FALSE;
+
        DBG2(DBG_IKE, "IKE_SA %s[%d] state change: %N => %N",
                 get_name(this), this->unique_id,
                 ike_sa_state_names, this->state,
@@ -679,12 +681,7 @@ METHOD(ike_sa_t, set_state, void,
                                        lib->scheduler->schedule_job(lib->scheduler, job, t);
                                        DBG1(DBG_IKE, "maximum IKE_SA lifetime %ds", t);
                                }
-
-                               /* start DPD checks */
-                               if (this->peer_cfg->get_dpd(this->peer_cfg))
-                               {
-                                       send_dpd(this);
-                               }
+                               trigger_dpd = this->peer_cfg->get_dpd(this->peer_cfg);
                        }
                        break;
                }
@@ -701,6 +698,11 @@ METHOD(ike_sa_t, set_state, void,
        }
        charon->bus->ike_state_change(charon->bus, &this->public, state);
        this->state = state;
+
+       if (trigger_dpd)
+       {
+               send_dpd(this);
+       }
 }
 
 METHOD(ike_sa_t, reset, void,