Skip to content

Commit

Permalink
Corrected destructor loop to clear all pending events
Browse files Browse the repository at this point in the history
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
  • Loading branch information
deepikabhavnani authored and geky committed Aug 4, 2019
1 parent 023a1d9 commit 74928f2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions equeue.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ int equeue_create_inplace(equeue_t *q, size_t size, void *buffer) {
void equeue_destroy(equeue_t *q) {
// call destructors on pending events
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) {
e->dtor(e + 1);
}
}
if (es->dtor) {
es->dtor(es + 1);
}
}

// notify background timer
if (q->background.update) {
q->background.update(q->background.timer, -1);
Expand Down

0 comments on commit 74928f2

Please sign in to comment.