Destroy active task list before queued tasks
authorThomas Egerer <thomas.egerer@secunet.com>
Mon, 16 Jan 2012 16:41:47 +0000 (17:41 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 18 Jan 2012 09:06:54 +0000 (10:06 +0100)
Since active task's destruction might result in adopting tasks from a
rekeyed ike sa it seems better to first destroy the active task list and
then destroy all queued tasks. This way adoption is possible at all,
while otherwise the queued task list would be empty.

src/libcharon/sa/task_manager.c

index 473bf34..dad533b 100644 (file)
@@ -159,15 +159,15 @@ struct private_task_manager_t {
  */
 static void flush(private_task_manager_t *this)
 {
  */
 static void flush(private_task_manager_t *this)
 {
-       this->queued_tasks->destroy_offset(this->queued_tasks,
-                                                                               offsetof(task_t, destroy));
-       this->queued_tasks = linked_list_create();
        this->passive_tasks->destroy_offset(this->passive_tasks,
                                                                                offsetof(task_t, destroy));
        this->passive_tasks = linked_list_create();
        this->active_tasks->destroy_offset(this->active_tasks,
                                                                                offsetof(task_t, destroy));
        this->active_tasks = linked_list_create();
        this->passive_tasks->destroy_offset(this->passive_tasks,
                                                                                offsetof(task_t, destroy));
        this->passive_tasks = linked_list_create();
        this->active_tasks->destroy_offset(this->active_tasks,
                                                                                offsetof(task_t, destroy));
        this->active_tasks = linked_list_create();
+       this->queued_tasks->destroy_offset(this->queued_tasks,
+                                                                               offsetof(task_t, destroy));
+       this->queued_tasks = linked_list_create();
 }
 
 /**
 }
 
 /**