From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@freelists.org Cc: kostja@tarantool.org Subject: [tarantool-patches] [PATCH 3/6] swim: factor out 'update' part of swim_member_upsert() Date: Fri, 12 Apr 2019 01:22:27 +0300 [thread overview] Message-ID: <77f22820198bd3234666c6cd28b629480c9dd2d5.1555021137.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1555021137.git.v.shpilevoy@tarantool.org> In-Reply-To: <cover.1555021137.git.v.shpilevoy@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)
next prev parent reply other threads:[~2019-04-11 22:22 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-11 22:22 [tarantool-patches] [PATCH 0/6] swim payload Vladislav Shpilevoy 2019-04-11 22:22 ` [tarantool-patches] [PATCH 1/6] swim: factor out MP_BIN decoding from swim_decode_uuid Vladislav Shpilevoy 2019-04-11 23:09 ` [tarantool-patches] " Konstantin Osipov 2019-04-12 19:23 ` Vladislav Shpilevoy 2019-04-11 22:22 ` [tarantool-patches] [PATCH 2/6] swim: replace event_bin and member_bin with the passport Vladislav Shpilevoy 2019-04-11 23:10 ` [tarantool-patches] " Konstantin Osipov 2019-04-12 19:23 ` Vladislav Shpilevoy 2019-04-11 22:22 ` Vladislav Shpilevoy [this message] 2019-04-11 23:11 ` [tarantool-patches] Re: [PATCH 3/6] swim: factor out 'update' part of swim_member_upsert() Konstantin Osipov 2019-04-12 19:23 ` Vladislav Shpilevoy 2019-04-11 22:22 ` [tarantool-patches] [PATCH 4/6] test: generalize SWIM fake descriptor filters Vladislav Shpilevoy 2019-04-11 23:11 ` [tarantool-patches] " Konstantin Osipov 2019-04-12 19:23 ` Vladislav Shpilevoy 2019-04-11 22:22 ` [tarantool-patches] [PATCH 5/6] test: introduce new SWIM packet filter by component names Vladislav Shpilevoy 2019-04-11 23:11 ` [tarantool-patches] " Konstantin Osipov 2019-04-12 19:23 ` Vladislav Shpilevoy 2019-04-11 22:22 ` [tarantool-patches] [PATCH 6/6] swim: introduce payload Vladislav Shpilevoy 2019-04-18 15:12 ` [tarantool-patches] " Konstantin Osipov 2019-04-18 17:43 ` Vladislav Shpilevoy 2019-04-18 18:03 ` Konstantin Osipov 2019-04-18 20:40 ` Vladislav Shpilevoy 2019-04-18 17:43 ` [tarantool-patches] [PATCH 5.5/6] swim: rename TTL to TTD Vladislav Shpilevoy 2019-04-18 17:48 ` [tarantool-patches] " Konstantin Osipov 2019-04-18 20:40 ` Vladislav Shpilevoy 2019-04-18 18:16 ` [tarantool-patches] [PATCH 7/6] swim: drop incarnation_inc parameter from update() routines Vladislav Shpilevoy 2019-04-18 18:20 ` [tarantool-patches] " Konstantin Osipov 2019-04-18 20:40 ` Vladislav Shpilevoy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=77f22820198bd3234666c6cd28b629480c9dd2d5.1555021137.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH 3/6] swim: factor out '\''update'\'' part of swim_member_upsert()' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox