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 1002B29903 for ; Thu, 11 Apr 2019 18:22:34 -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 vajFuK4PzrFf for ; Thu, 11 Apr 2019 18:22:33 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 9FD04299CF for ; Thu, 11 Apr 2019 18:22:33 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 3/6] swim: factor out 'update' part of swim_member_upsert() Date: Fri, 12 Apr 2019 01:22:27 +0300 Message-Id: <77f22820198bd3234666c6cd28b629480c9dd2d5.1555021137.git.v.shpilevoy@tarantool.org> In-Reply-To: References: In-Reply-To: References: 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 Move 'update' logic into a separate function, because in the next commits it is going to become more complicated due to payload introduction, and it would be undesirable to clog the upsert() function with payload-specific code. Part of #3234 --- src/lib/swim/swim.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index 0e7f51adf..2dac6eedd 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -1055,6 +1055,22 @@ swim_update_member_addr(struct swim *swim, struct swim_member *member, } } +/** + * Update an existing member with a new definition. It is expected + * that @a def has an incarnation not older that @a member has. + */ +static inline void +swim_update_member(struct swim *swim, const struct swim_member_def *def, + struct swim_member *member) +{ + assert(member != swim->self); + assert(def->incarnation >= member->incarnation); + if (def->incarnation > member->incarnation) + swim_update_member_addr(swim, member, &def->addr, 0); + swim_update_member_inc_status(swim, member, def->status, + def->incarnation); +} + /** * Update or create a member by its definition, received from a * remote instance. @@ -1099,9 +1115,7 @@ swim_upsert_member(struct swim *swim, const struct swim_member_def *def, if (member != self) { if (def->incarnation < member->incarnation) goto skip; - swim_update_member_addr(swim, member, &def->addr, 0); - swim_update_member_inc_status(swim, member, def->status, - def->incarnation); + swim_update_member(swim, def, member); return 0; } /* -- 2.17.2 (Apple Git-113)