Support flushing of single tasks queues in IKEv1 task manager

This commit is contained in:
Martin Willi
2012-03-20 17:31:18 +01:00
parent 9862852823
commit 0f61964ed7
+16 -9
View File
@@ -156,20 +156,27 @@ struct private_task_manager_t {
double retransmit_base;
};
/**
* 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);
}
/**