From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 1C3202EC74 for ; Wed, 15 May 2019 15:36:55 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MTMsNIEjYhCE for ; Wed, 15 May 2019 15:36:55 -0400 (EDT) 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 turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id C98A52EBFD for ; Wed, 15 May 2019 15:36:48 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 01/10] swim: fix an assertion on attempt to chage timeouts Date: Wed, 15 May 2019 22:36:37 +0300 Message-Id: <4c67b85cde841083e2e36a8dafb8ed9a1e162986.1557948687.git.v.shpilevoy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: kostja@tarantool.org Appeared, that libev does not allow to change ev_timer values in flight. A timer, reset via ev_timer_set(), should be restarted, because the function changes 'ev_timer.at', which in turn is used internally by timer routines. Part of #3234 --- src/lib/swim/swim.c | 17 ++++++++++++----- src/lib/swim/swim_ev.h | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index 54c5b3250..725ebf222 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -1797,11 +1797,18 @@ swim_cfg(struct swim *swim, const char *uri, double heartbeat_rate, } else { addr = swim->self->addr; } - if (swim->round_tick.repeat != heartbeat_rate && heartbeat_rate > 0) - swim_ev_timer_set(&swim->round_tick, 0, heartbeat_rate); - - if (swim->wait_ack_tick.repeat != ack_timeout && ack_timeout > 0) - swim_ev_timer_set(&swim->wait_ack_tick, 0, ack_timeout); + struct ev_timer *t = &swim->round_tick; + if (t->repeat != heartbeat_rate && heartbeat_rate > 0) { + swim_ev_timer_set(t, 0, heartbeat_rate); + if (swim_ev_is_active(t)) + swim_ev_timer_again(loop(), t); + } + t = &swim->wait_ack_tick; + if (t->repeat != ack_timeout && ack_timeout > 0) { + swim_ev_timer_set(t, 0, ack_timeout); + if (swim_ev_is_active(t)) + swim_ev_timer_again(loop(), t); + } if (new_self != NULL) { swim->self->status = MEMBER_LEFT; diff --git a/src/lib/swim/swim_ev.h b/src/lib/swim/swim_ev.h index b68ed9e19..fe261ff38 100644 --- a/src/lib/swim/swim_ev.h +++ b/src/lib/swim/swim_ev.h @@ -52,6 +52,8 @@ swim_ev_timer_again(struct ev_loop *loop, struct ev_timer *watcher); void swim_ev_timer_stop(struct ev_loop *loop, struct ev_timer *watcher); +#define swim_ev_is_active ev_is_active + #define swim_ev_init ev_init #define swim_ev_timer_init ev_timer_init -- 2.20.1 (Apple Git-117)