mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-26 07:03:59 +00:00
Merge pull request #1305 from donaldsharp/workqueue
lib: Free workqueue memory leak on free
This commit is contained in:
commit
4c6ed05e4e
@ -57,6 +57,22 @@ static void work_queue_item_free(struct work_queue_item *item)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void work_queue_item_remove(struct work_queue *wq,
|
||||||
|
struct work_queue_item *item)
|
||||||
|
{
|
||||||
|
assert(item && item->data);
|
||||||
|
|
||||||
|
/* call private data deletion callback if needed */
|
||||||
|
if (wq->spec.del_item_data)
|
||||||
|
wq->spec.del_item_data(wq, item->data);
|
||||||
|
|
||||||
|
work_queue_item_dequeue(wq, item);
|
||||||
|
|
||||||
|
work_queue_item_free(item);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* create new work queue */
|
/* create new work queue */
|
||||||
struct work_queue *work_queue_new(struct thread_master *m,
|
struct work_queue *work_queue_new(struct thread_master *m,
|
||||||
const char *queue_name)
|
const char *queue_name)
|
||||||
@ -90,6 +106,12 @@ void work_queue_free(struct work_queue *wq)
|
|||||||
if (wq->thread != NULL)
|
if (wq->thread != NULL)
|
||||||
thread_cancel(wq->thread);
|
thread_cancel(wq->thread);
|
||||||
|
|
||||||
|
while (!work_queue_empty(wq)) {
|
||||||
|
struct work_queue_item *item = work_queue_last_item(wq);
|
||||||
|
|
||||||
|
work_queue_item_remove(wq, item);
|
||||||
|
}
|
||||||
|
|
||||||
listnode_delete(work_queues, wq);
|
listnode_delete(work_queues, wq);
|
||||||
|
|
||||||
XFREE(MTYPE_WORK_QUEUE_NAME, wq->name);
|
XFREE(MTYPE_WORK_QUEUE_NAME, wq->name);
|
||||||
@ -137,22 +159,6 @@ void work_queue_add(struct work_queue *wq, void *data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void work_queue_item_remove(struct work_queue *wq,
|
|
||||||
struct work_queue_item *item)
|
|
||||||
{
|
|
||||||
assert(item && item->data);
|
|
||||||
|
|
||||||
/* call private data deletion callback if needed */
|
|
||||||
if (wq->spec.del_item_data)
|
|
||||||
wq->spec.del_item_data(wq, item->data);
|
|
||||||
|
|
||||||
work_queue_item_dequeue(wq, item);
|
|
||||||
|
|
||||||
work_queue_item_free(item);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void work_queue_item_requeue(struct work_queue *wq, struct work_queue_item *item)
|
static void work_queue_item_requeue(struct work_queue *wq, struct work_queue_item *item)
|
||||||
{
|
{
|
||||||
work_queue_item_dequeue(wq, item);
|
work_queue_item_dequeue(wq, item);
|
||||||
|
Loading…
Reference in New Issue
Block a user