From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 22A8043E880 for ; Mon, 23 Mar 2020 19:37:25 +0300 (MSK) Received: by mail-lj1-f196.google.com with SMTP id r24so15392417ljd.4 for ; Mon, 23 Mar 2020 09:37:25 -0700 (PDT) Date: Mon, 23 Mar 2020 19:37:23 +0300 From: Konstantin Osipov Message-ID: <20200323163723.GB5491@atlas> References: <00ed3e57ada08fde8ef7f80b8afcf34ccf901e22.1584978381.git.sergepetrenko@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00ed3e57ada08fde8ef7f80b8afcf34ccf901e22.1584978381.git.sergepetrenko@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v3 1/4] vclock: add an ability to set individual clock components List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org * Serge Petrenko [20/03/23 19:23]: > This is needed to 'hide' 0-th vclock component in replication responses. I think the name should reflect the magic that happens in this function. How about vclock_reset()? > > Follow-up #3186 > Prerequisite #4114 > --- > src/box/vclock.c | 15 +++++++++++++++ > src/box/vclock.h | 11 +++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/src/box/vclock.c b/src/box/vclock.c > index 90ae27591..302c0438d 100644 > --- a/src/box/vclock.c > +++ b/src/box/vclock.c > @@ -37,6 +37,21 @@ > #include "diag.h" > #include "tt_static.h" > > +void > +vclock_set(struct vclock *vclock, uint32_t replica_id, int64_t lsn) > +{ > + assert(lsn >= 0); > + assert(replica_id < VCLOCK_MAX); > + vclock->signature -= vclock_get(vclock, replica_id); > + if (lsn == 0) { > + vclock->map &= ~(1 << replica_id); > + return; > + } > + vclock->lsn[replica_id] = lsn; > + vclock->map |= 1 << replica_id; > + vclock->signature += lsn; > +} > + > int64_t > vclock_follow(struct vclock *vclock, uint32_t replica_id, int64_t lsn) > { > diff --git a/src/box/vclock.h b/src/box/vclock.h > index 79e5a1bc0..7dc69015f 100644 > --- a/src/box/vclock.h > +++ b/src/box/vclock.h > @@ -211,6 +211,17 @@ vclock_calc_sum(const struct vclock *vclock) > return sum; > } > > +/** > + * Set vclock component represented by replica id to the desired > + * value. Why is it necessary and how is it used? Should be in this comment. The use case is still not very clear from the commit comment. > + * > + * @param vclock Vector clock. > + * @param replica_id Replica identifier. > + * @param lsn Lsn to set > + */ > +void > +vclock_set(struct vclock *vclock, uint32_t replica_id, int64_t lsn); > + > static inline int64_t > vclock_sum(const struct vclock *vclock) -- Konstantin Osipov, Moscow, Russia https://scylladb.com