From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [217.69.128.41]) (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 0EDA643E89F for ; Fri, 27 Mar 2020 13:23:00 +0300 (MSK) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.40.2.2.4\)) From: Serge Petrenko In-Reply-To: <20200323163723.GB5491@atlas> Date: Fri, 27 Mar 2020 13:22:58 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <71B97126-6C1A-40D0-8484-EF075416328E@tarantool.org> References: <00ed3e57ada08fde8ef7f80b8afcf34ccf901e22.1584978381.git.sergepetrenko@tarantool.org> <20200323163723.GB5491@atlas> 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: Konstantin Osipov Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy > 23 =D0=BC=D0=B0=D1=80=D1=82=D0=B0 2020 =D0=B3., =D0=B2 19:37, = Konstantin Osipov =D0=BD=D0=B0=D0=BF=D0=B8=D1=81= =D0=B0=D0=BB(=D0=B0): >=20 > * Serge Petrenko [20/03/23 19:23]: >> This is needed to 'hide' 0-th vclock component in replication = responses. >=20 > I think the name should reflect the magic that happens in this > function. >=20 > How about vclock_reset()? No problem, fixed. >=20 >>=20 >> Follow-up #3186 >> Prerequisite #4114 >> --- >> src/box/vclock.c | 15 +++++++++++++++ >> src/box/vclock.h | 11 +++++++++++ >> 2 files changed, 26 insertions(+) >>=20 >> 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" >>=20 >> +void >> +vclock_set(struct vclock *vclock, uint32_t replica_id, int64_t lsn) >> +{ >> + assert(lsn >=3D 0); >> + assert(replica_id < VCLOCK_MAX); >> + vclock->signature -=3D vclock_get(vclock, replica_id); >> + if (lsn =3D=3D 0) { >> + vclock->map &=3D ~(1 << replica_id); >> + return; >> + } >=20 >> + vclock->lsn[replica_id] =3D lsn; >> + vclock->map |=3D 1 << replica_id; >> + vclock->signature +=3D 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; >> } >>=20 >> +/** >> + * Set vclock component represented by replica id to the desired >> + * value. >=20 > Why is it necessary and how is it used? Should be in this comment.=20 > The use case is still not very clear from the commit comment. >=20 I amended both the commit message and the comment. Please see v4 >> + * >> + * @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) >=20 > --=20 > Konstantin Osipov, Moscow, Russia > https://scylladb.com -- Serge Petrenko sergepetrenko@tarantool.org