From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (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 8A68E469719 for ; Fri, 13 Nov 2020 13:17:30 +0300 (MSK) References: <20201112195121.191366-1-gorcunov@gmail.com> <20201112195121.191366-11-gorcunov@gmail.com> From: Serge Petrenko Message-ID: <07fbedb0-9d4f-893f-a8b4-db6eac975428@tarantool.org> Date: Fri, 13 Nov 2020 13:17:29 +0300 MIME-Version: 1.0 In-Reply-To: <20201112195121.191366-11-gorcunov@gmail.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [Tarantool-patches] [PATCH 10/11] relay: use verbose names for fibers List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov , tml Cc: Vladislav Shpilevoy 12.11.2020 22:51, Cyrill Gorcunov пишет: > Usually we use _f postfix for fiber's loop functions > and using same postfix for the fiber instance itself > looks inconsistent. > > Same time if we grep for "struct fibers" we see a number > of places where fiber instances are postfixed with _fiber. > > Thus lets make the same in relay fiber code: > > - use explicit reader_fiber name for a reader > - use relay_fiber name for the joint relay fiber > which depends on the reader, moreover this explicit > name allows to note that the reader cancels the bound > fiber if error happens. Applier also has incosistent naming. applier->reader and applier->writer. Maybe apply the same naming for relay? Make relay_f relay_writer. And reader_fiber -> relay_reader. It looks better in my opinion. > > Signed-off-by: Cyrill Gorcunov > --- > src/box/relay.cc | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/src/box/relay.cc b/src/box/relay.cc > index fa3dc3a75..a9522d30c 100644 > --- a/src/box/relay.cc > +++ b/src/box/relay.cc > @@ -539,7 +539,7 @@ int > relay_reader_f(va_list ap) > { > struct relay *relay = va_arg(ap, struct relay *); > - struct fiber *relay_f = va_arg(ap, struct fiber *); > + struct fiber *relay_fiber = va_arg(ap, struct fiber *); > > struct ibuf ibuf; > struct ev_io io; > @@ -557,7 +557,7 @@ relay_reader_f(va_list ap) > } > } catch (Exception *e) { > relay_set_error(relay, e); > - fiber_cancel(relay_f); > + fiber_cancel(relay_fiber); > } > ibuf_destroy(&ibuf); > return 0; > @@ -688,9 +688,10 @@ relay_subscribe_f(va_list ap) > /* Start fiber for receiving replica acks. */ > char name[FIBER_NAME_MAX]; > snprintf(name, sizeof(name), "%s:%s", fiber()->name, "reader"); > - struct fiber *reader = fiber_new_xc(name, relay_reader_f); > - fiber_set_joinable(reader, true); > - fiber_start(reader, relay, fiber()); > + struct fiber *reader_fiber = fiber_new_xc(name, relay_reader_f); > + struct fiber *relay_fiber = fiber(); > + fiber_set_joinable(reader_fiber, true); > + fiber_start(reader_fiber, relay, relay_fiber); > > /* > * If the replica happens to be up to date on subscribe, > @@ -771,8 +772,8 @@ relay_subscribe_f(va_list ap) > wal_clear_watcher(&relay->wal_watcher, cbus_process); > > /* Join ack reader fiber. */ > - fiber_cancel(reader); > - fiber_join(reader); > + fiber_cancel(reader_fiber); > + fiber_join(reader_fiber); > > /* Destroy cpipe to tx. */ > cbus_unpair(&relay->tx_pipe, &relay->relay_pipe, -- Serge Petrenko