Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
veimmone opened this issue Feb 21, 2024 · 2 comments
Closed

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

veimmone opened this issue Feb 21, 2024 · 2 comments

Comments

@veimmone
Copy link

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.

@sphaero
Copy link
Contributor

sphaero commented Mar 8, 2024

can you send a PR?

@veimmone
Copy link
Author

veimmone commented Apr 2, 2024

My colleague found the time to spearhead making the PR: #2282

@sphaero sphaero closed this as completed Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants