From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (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 5B50642F4AD for ; Thu, 2 Jul 2020 22:41:00 +0300 (MSK) Date: Thu, 2 Jul 2020 22:40:48 +0300 From: Sergey Kaplun Message-ID: <20200702194048.GA32264@root> References: <20200629203134.30177-1-skaplun@tarantool.org> <20200702155347.GJ2256@grain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200702155347.GJ2256@grain> Subject: Re: [Tarantool-patches] [DRAFT v1] replication: track information about replica List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy Hi! Thanks for the review! On 02.07.20, Cyrill Gorcunov wrote: > On Mon, Jun 29, 2020 at 11:31:34PM +0300, Sergey Kaplun wrote: > ... > > > > +static int > > +relay_on_state_f(struct trigger *trigger, void *event) > > +{ > > Sergey, I'll review the patch with more attention tomorrow, still > here are some notes which I can point early. > > - please don't name the trigger function with _f postfix, we usually > do this for cord thread runners (I know here are a few exceptions > but they are simply misnamed) > Yup, thanks! > > + struct relay *relay = (struct relay *)event; > > + (void)trigger; > > You can easily exit early > > if (relay_get_state(relay) == RELAY_OFF) > return 0; > > shifting the rest of the code left. Still up to you I do not insist. > Nice point! Early return looks much better! > > Do we really need to call diag_raise() here? > > > + int rc; > > + switch (relay_get_state(relay)) { > ... > > + } > > + if (rc != 0) > > + diag_raise(); > > And here. IIRC usually triggers simply return -1 on error. > The left of the patch is trimmed for now. I think we should not raise an error inside relay. Is say_error enough if something goes wrong? I will send new version with separate letter. -- Best regards, Sergey Kaplun