czmq icon indicating copy to clipboard operation
czmq copied to clipboard

zloop allows calling start() again but timer removal fails then

Open veimmone opened this issue 1 year ago • 1 comments

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.

veimmone avatar Feb 21 '24 11:02 veimmone

can you send a PR?

sphaero avatar Mar 08 '24 09:03 sphaero

My colleague found the time to spearhead making the PR: https://github.com/zeromq/czmq/pull/2282

veimmone avatar Apr 02 '24 07:04 veimmone