From: Alexander Turenko <alexander.turenko@tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH 1/1] netbox: don't fire on_connect() at schema update Date: Tue, 5 Nov 2019 18:00:32 +0300 [thread overview] Message-ID: <20191105150032.lf3eujv2ddygsijl@tkn_work_nb> (raw) In-Reply-To: <cd8c59d2-114a-91dc-557f-c0290ee94456@tarantool.org> On Tue, Nov 05, 2019 at 05:12:09PM +0300, Vladislav Shpilevoy wrote: > Hi! Thanks for the review! > > So, in short, you are against assuming that errno ~= nil always > means that it is a terminal state. 'error_reconnect' is not the terminal state, but yes: I'm against assuming that errno ~= nil means anything about a current state. > I don't think that error ~= nil is a bad idea, but ok, I don't mind > checking the states explicitly as it was before. I'm more comfortable with this approach, thanks! The patch LGTM. CCed Kirill. https://github.com/tarantool/tarantool/issues/4593 https://github.com/tarantool/tarantool/tree/gerold103/gh-4593-netbox-on_connect > > Force pushed to the branch: > ======================================================================= > > diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua > index 696b30fd9..c2e1bb9c4 100644 > --- a/src/box/lua/net_box.lua > +++ b/src/box/lua/net_box.lua > @@ -933,7 +933,8 @@ local function new_sm(host, port, opts, connection, greeting) > remote._is_connected = true > remote._on_connect:run(remote) > end > - elseif errno ~= nil then > + elseif state == 'error' or state == 'error_reconnect' or > + state == 'closed' then > if was_connected then > remote._is_connected = false > remote._on_disconnect:run(remote) > > ======================================================================= > > Let's consider unix errno: it should not be used as a primary source of > > information **whether** an error occurs. You always check a return code > > and only if it says that an error occurs we can consider 'errno' as a > > source of information **which kind** of error occurs. > > Yes, but it is not unix errno. Here the error code is rather like a > return value. Nil means everything is ok, not nil means that the state > machine has reached a terminal state. I think that the name 'errno' is not good here, but it is debatable and surely should not be changed within the bugfix issue. > > That is why I generally against using of errno / diagnostic area as > > sources of information whether an error occurs: in context of Unix APIs > > this would be an improper usage. > > > > I would mark states as 'connected' and 'disconnected' explicitly: > > > > | -- XXX: Give a comment why, say, 'fetch_schema' is not here. > > | local function is_state_connected(state) > > | return state == 'active' > > | end > > | > > | local disconnected_states = { > > | initial = true, > > | error = true, > > | error_reconnect = true, > > | closed = true, > > | } > > | > > | local function is_state_disconnected(state) > > | return disconnected_states[state] > > | end > > This way is the same as it was before - checking of the states > explicitly, by their names. Previously I would need to patch > callback() on any update in the state set. In your proposal I > need to update these functions. So it is the same, it does not > simplify anything. is_state_disconnected() can be reused in set_state() too, but I don't mind of checking states explicitly.
next prev parent reply other threads:[~2019-11-05 15:00 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-10-29 21:43 Vladislav Shpilevoy 2019-10-29 22:03 ` Cyrill Gorcunov 2019-10-29 23:51 ` Vladislav Shpilevoy 2019-11-05 13:12 ` Alexander Turenko 2019-11-05 14:12 ` Vladislav Shpilevoy 2019-11-05 15:00 ` Alexander Turenko [this message] 2019-11-05 16:34 ` Kirill Yukhin 2019-11-06 0:56 ` Alexander Turenko 2019-11-06 13:44 ` Kirill Yukhin
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=20191105150032.lf3eujv2ddygsijl@tkn_work_nb \ --to=alexander.turenko@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 1/1] netbox: don'\''t fire on_connect() at schema update' \ /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