Skip to content
Browse files

safer stats_event_listener_remove

  • Loading branch information...
1 parent ec38225 commit 74ccd3f7863922209a6e46366e4ed274af232b9a @tmm1 committed
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/dumpstats.c
View
12 src/dumpstats.c
@@ -61,10 +61,18 @@ static inline void stats_event_listener_add(struct session *s)
static inline void stats_event_listener_remove(struct session *s)
{
- if (!LIST_ISEMPTY(&stats_event_listeners)) {
- LIST_DEL(&s->data_ctx.events.list);
+ int found = 0;
+ struct session *curr;
+ list_for_each_entry(curr, &stats_event_listeners, data_ctx.events.list) {
+ if (curr == s) {
+ found = 1;
+ break;
+ }
}
+ if (found)
+ LIST_DEL(&s->data_ctx.events.list);
+
/* Re-initialize stats output */
memset(&s->data_ctx.stats, 0, sizeof(s->data_ctx.stats));
}

0 comments on commit 74ccd3f

Please sign in to comment.
Something went wrong with that request. Please try again.