Support flushing of single tasks queues in IKEv1 task manager
authorMartin Willi <martin@revosec.ch>
Mon, 12 Dec 2011 17:01:21 +0000 (18:01 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 20 Mar 2012 16:31:18 +0000 (17:31 +0100)
src/libcharon/sa/task_manager_v1.c

index 2af0ba2..cfa67b0 100755 (executable)
@@ -157,19 +157,26 @@ struct private_task_manager_t {
 };
 
 /**
+ * Flush a single task queue
+ */
+static void flush_queue(private_task_manager_t *this, linked_list_t *list)
+{
+       task_t *task;
+
+       while (list->remove_last(list, (void**)&task) == SUCCESS)
+       {
+               task->destroy(task);
+       }
+}
+
+/**
  * flush all tasks in the task manager
  */
 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();
+       flush_queue(this, this->queued_tasks);
+       flush_queue(this, this->passive_tasks);
+       flush_queue(this, this->active_tasks);
 }
 
 /**