From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C98FB45C305 for ; Sun, 13 Dec 2020 20:15:33 +0300 (MSK) From: Vladislav Shpilevoy Date: Sun, 13 Dec 2020 18:15:23 +0100 Message-Id: <641666dad7ac4c633b173800f2dc49438098caae.1607879643.git.v.shpilevoy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/8] fakesys: fix ev_is_active not working on fake timers List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org 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)