From: Martin Willi Date: Mon, 12 Dec 2011 17:01:21 +0000 (+0100) Subject: Support flushing of single tasks queues in IKEv1 task manager X-Git-Tag: 5.0.0~338^2~9^2~255 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f61964ed75ded8c40dce8413943f343146bc840;p=thirdparty%2Fstrongswan.git Support flushing of single tasks queues in IKEv1 task manager --- diff --git a/src/libcharon/sa/task_manager_v1.c b/src/libcharon/sa/task_manager_v1.c index 2af0ba2ac5..cfa67b0793 100755 --- a/src/libcharon/sa/task_manager_v1.c +++ b/src/libcharon/sa/task_manager_v1.c @@ -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); } /**