From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Cyrill Gorcunov <gorcunov@gmail.com>, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH 1/1] fiber_cond: remove rlist_shift usages Date: Tue, 2 Mar 2021 12:04:47 +0300 [thread overview] Message-ID: <3102df69-ed4b-f5e6-daca-8afb1aef29c9@tarantool.org> (raw) In-Reply-To: <YD3rQB1d6mKeqKbV@grain> 02.03.2021 10:37, Cyrill Gorcunov пишет: > On Mon, Mar 01, 2021 at 11:23:13PM +0100, Vladislav Shpilevoy wrote: >> @@ -94,7 +94,7 @@ fiber_cond_broadcast(struct fiber_cond *e) >> { >> while (! rlist_empty(&e->waiters)) { >> struct fiber *f; >> - f = rlist_shift_entry(&e->waiters, struct fiber, state); >> + f = rlist_first_entry(&e->waiters, struct fiber, state); >> fiber_wakeup(f); >> } >> } > The fiber_wakeup ignores > > if (f->flags & (FIBER_IS_READY | FIBER_IS_DEAD)) > return; > > can't we hit the situation where fiber_cond_broadcast called with > dead fiber so that it won't be deleted from the list with new code? Good point, I never thought of this. Once a fiber dies, it's removed from any list that could wake it up: /* reset pending wakeups */ rlist_del(&fiber->state); And FIBER_IS_READY is set only from fiber_wakeup() to guard from concurrent wake-ups. So the patch must be fine indeed. Vlad, LGTM. > > Actually looking into fiber_loop code I see > > static void > fiber_loop(MAYBE_UNUSED void *data) > { > ... > fiber->flags |= FIBER_IS_DEAD; > while (! rlist_empty(&fiber->wake)) { > struct fiber *f; > f = rlist_shift_entry(&fiber->wake, struct fiber, > state); > assert(f != fiber); > fiber_wakeup(f); > } > > so it should be safe with your patch, but just to make sure I didn't > miss something obvious. -- Serge Petrenko
next prev parent reply other threads:[~2021-03-02 9:04 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-01 22:23 Vladislav Shpilevoy via Tarantool-patches 2021-03-02 7:37 ` Cyrill Gorcunov via Tarantool-patches 2021-03-02 7:54 ` Cyrill Gorcunov via Tarantool-patches 2021-03-02 9:04 ` Serge Petrenko via Tarantool-patches [this message] 2021-03-03 21:43 ` Vladislav Shpilevoy via Tarantool-patches 2021-03-03 21:37 ` Vladislav Shpilevoy via Tarantool-patches
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=3102df69-ed4b-f5e6-daca-8afb1aef29c9@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=sergepetrenko@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 1/1] fiber_cond: remove rlist_shift usages' \ /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