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

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun Dec 13 20:15:23 MSK 2020


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,
-- 
2.24.3 (Apple Git-128)



More information about the Tarantool-patches mailing list