Corrected destructor loop to clear all pending events

In `equeue_destroy` the external loop was for main events linked
list and internal loop for siblings.
Siblings start was not initialized correctly for each main link
pull/9144/head
deepikabhavnani 2018-12-19 11:50:33 -06:00
parent b893d5681f
commit 01b2530a7d
1 changed files with 4 additions and 2 deletions

View File

@ -108,13 +108,15 @@ void equeue_destroy(equeue_t *q)
{ {
// call destructors on pending events // call destructors on pending events
for (struct equeue_event *es = q->queue; es; es = es->next) { for (struct equeue_event *es = q->queue; es; es = es->next) {
for (struct equeue_event *e = q->queue; e; e = e->sibling) { for (struct equeue_event *e = es->sibling; e; e = e->sibling) {
if (e->dtor) { if (e->dtor) {
e->dtor(e + 1); e->dtor(e + 1);
} }
} }
if (es->dtor) {
es->dtor(es + 1);
}
} }
// notify background timer // notify background timer
if (q->background.update) { if (q->background.update) {
q->background.update(q->background.timer, -1); q->background.update(q->background.timer, -1);