[Tarantool-patches] [PATCH 1/8] fakesys: fix ev_is_active not working on fake timers

Serge Petrenko sergepetrenko at tarantool.org
Tue Dec 15 12:42:44 MSK 2020


13.12.2020 20:15, Vladislav Shpilevoy пишет:
> fakeev timers didn't set 'active' flag for ev_watcher objects.
>
> Because of that if fakeev_timer_start() was called, the timer
> wasn't visible as 'active' via libev API.
>
> Fakeev is supposed to be a drop-in simulation of libev, so it
> should "work" exactly the same.
> ---
>   src/lib/fakesys/fakeev.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/src/lib/fakesys/fakeev.c b/src/lib/fakesys/fakeev.c
> index 20fab916b..8273c7ca8 100644
> --- a/src/lib/fakesys/fakeev.c
> +++ b/src/lib/fakesys/fakeev.c
> @@ -181,6 +181,8 @@ fakeev_timer_event_delete(struct fakeev_event *e)
>   {
>   	assert(e->type == FAKEEV_EVENT_TIMER);
>   	struct fakeev_timer_event *te = (struct fakeev_timer_event *)e;
> +	assert(te->watcher->active == 1);
> +	te->watcher->active = 0;
>   	mh_int_t rc = mh_i64ptr_find(events_hash, (uint64_t) te->watcher, NULL);
>   	assert(rc != mh_end(events_hash));
>   	mh_i64ptr_del(events_hash, rc, NULL);
> @@ -209,6 +211,8 @@ fakeev_timer_event_process(struct fakeev_event *e, struct ev_loop *loop)
>   static void
>   fakeev_timer_event_new(struct ev_watcher *watcher, double delay)
>   {
> +	assert(watcher->active == 0);
> +	watcher->active = 1;
>   	struct fakeev_timer_event *e = malloc(sizeof(*e));
>   	assert(e != NULL);
>   	fakeev_event_create(&e->base, FAKEEV_EVENT_TIMER, delay,

Hi! Thanks for the patch!

LGTM.

-- 
Serge Petrenko



More information about the Tarantool-patches mailing list