Use enumerator for queued_tasks migration to avoid infinite loop
authorThomas Egerer <thomas.egerer@secunet.com>
Wed, 30 Jun 2010 11:10:56 +0000 (13:10 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 30 Jun 2010 11:24:43 +0000 (13:24 +0200)
src/libcharon/sa/task_manager.c

index 568f31a..a688264 100644 (file)
@@ -986,6 +986,7 @@ METHOD(task_manager_t, busy, bool,
 METHOD(task_manager_t, reset, void,
        private_task_manager_t *this, u_int32_t initiate, u_int32_t respond)
 {
+       enumerator_t *enumerator;
        task_t *task;
 
        /* reset message counters and retransmit packets */
@@ -1004,12 +1005,13 @@ METHOD(task_manager_t, reset, void,
        this->initiating.type = EXCHANGE_TYPE_UNDEFINED;
 
        /* reset queued tasks */
-       while (this->queued_tasks->remove_last(this->queued_tasks,
-                                                                                  (void**)&task) == SUCCESS)
+       enumerator = this->queued_tasks->create_enumerator(this->queued_tasks);
+       while (enumerator->enumerate(enumerator, &task))
        {
                task->migrate(task, this->ike_sa);
-               this->queued_tasks->insert_first(this->queued_tasks, task);
        }
+       enumerator->destroy(enumerator);
+
        /* reset active tasks */
        while (this->active_tasks->remove_last(this->active_tasks,
                                                                                   (void**)&task) == SUCCESS)