The terminated member in _zloop_t is only used in zloop_timer_end to check whether the timer can be removed immediately or via the zombie list.
The terminated member is initialized to false in zloop_new through zmalloc. It is set to true before returning from zloop_start.
Now, if you call zloop_start again on the same zloop_t object, terminated is still true, and then if you call zloop_timer_end from a reactor callback, you end up touching self->timers against the warning on line 581 in zloop.c.
Judging by the test suite, calling zloop_start repeatedly is a valid use case.
The fix seems simple enough; self->terminated = false; before the main reactor loop in zloop_start.
The
terminated
member in_zloop_t
is only used inzloop_timer_end
to check whether the timer can be removed immediately or via the zombie list.The
terminated
member is initialized tofalse
inzloop_new
throughzmalloc
. It is set totrue
before returning fromzloop_start
.Now, if you call
zloop_start
again on the samezloop_t
object,terminated
is still true, and then if you callzloop_timer_end
from a reactor callback, you end up touchingself->timers
against the warning on line 581 inzloop.c
.Judging by the test suite, calling
zloop_start
repeatedly is a valid use case.The fix seems simple enough;
self->terminated = false;
before the main reactor loop inzloop_start
.