From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: sergos@tarantool.org, tarantool-patches@dev.tarantool.org Cc: alexander.turenko@tarantool.org Subject: Re: [Tarantool-patches] [PATCH v2] core: handle fiber cancellation for fiber.cond Date: Mon, 16 Nov 2020 23:12:42 +0100 [thread overview] Message-ID: <bc416adf-d807-860d-6f65-95556b2cef6f@tarantool.org> (raw) In-Reply-To: <20201031162911.61876-1-sergos@tarantool.org> Hi! Thanks for the patch! Please, change subsystem name to 'fiber:'. 'core:' is too general. We have tons of stuff in libcore in addition to fibers. > Before this patch fiber.cond():wait() just returns for cancelled > fiber. In contrast fiber.channel():get() threw "fiber is > canceled" error. > This patch unify behaviour of channels and condvars and also fixes > related net.box module problem - it was impossible to interrupt > net.box call with fiber.cancel because it used fiber.cond under > the hood. Test cases for both bugs are added. Netbox hangs not because of using fiber.cond. But because it never calls testcancel(). Normally all looped fibers should do that. Talking of compatibility - I think it always was supposed to throw. luaT_fiber_cond_wait() calls luaL_testcancel(), but only when fiber_cond_wait_timeout() returns not 0, which was never the case for cancellation. So it was supposed to throw, but nobody covered it with a test. See 2 comments below. > Closes #4834 > Closes #5013 > > Co-authored-by: Oleg Babin <olegrok@tarantool.org> > diff --git a/src/box/box.cc b/src/box/box.cc > index 18568df3b..29f74e94b 100644 > --- a/src/box/box.cc > +++ b/src/box/box.cc > @@ -305,10 +305,9 @@ box_wait_ro(bool ro, double timeout) > { > double deadline = ev_monotonic_now(loop()) + timeout; > while (is_box_configured == false || box_is_ro() != ro) { > - if (fiber_cond_wait_deadline(&ro_cond, deadline) != 0) > - return -1; > - if (fiber_is_cancelled()) { > - diag_set(FiberIsCancelled); > + if (fiber_cond_wait_deadline(&ro_cond, deadline) != 0) { > + if (fiber_is_cancelled()) > + diag_set(FiberIsCancelled); > return -1; > } > } > diff --git a/src/lib/core/fiber_cond.c b/src/lib/core/fiber_cond.c > index 904a350d9..cc59eaafb 100644 > --- a/src/lib/core/fiber_cond.c > +++ b/src/lib/core/fiber_cond.c > @@ -108,6 +108,11 @@ fiber_cond_wait_timeout(struct fiber_cond *c, double timeout) > diag_set(TimedOut); > return -1; > } > + if (fiber_is_cancelled()) { > + if (diag_is_empty(diag_get())) > + diag_set(FiberIsCancelled); > + return -1; 1. Wtf? Why don't you set an error, when this is an error? And why do you do exactly the same in box_wait_ro() above? > + } > return 0; > }> diff --git a/test/box/net.box_fiber_cancel_gh-4834.result b/test/box/net.box_fiber_cancel_gh-4834.result > new file mode 100644 > index 000000000..4ed04bb61 > --- /dev/null > +++ b/test/box/net.box_fiber_cancel_gh-4834.result 2. This does not conform to our test file name pattern. Read this carefully: https://github.com/tarantool/tarantool/wiki/Code-review-procedure#testing
next prev parent reply other threads:[~2020-11-16 22:12 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-31 16:29 sergos 2020-11-01 10:13 ` Oleg Babin 2020-11-03 10:20 ` Sergey Ostanevich 2020-11-03 10:27 ` Oleg Babin 2020-11-04 10:00 ` Leonid Vasiliev 2020-11-16 22:12 ` Vladislav Shpilevoy 2020-11-18 22:05 ` Sergey Ostanevich 2020-11-22 16:01 ` Vladislav Shpilevoy 2020-11-23 21:47 ` Sergey Ostanevich 2020-11-24 7:31 ` Sergey Ostanevich 2020-11-04 10:00 ` Leonid Vasiliev 2020-11-05 20:42 ` Sergey Ostanevich 2020-11-10 21:16 ` Sergey Ostanevich 2020-11-12 20:15 ` Sergey Ostanevich 2020-11-13 8:26 ` Leonid Vasiliev 2020-11-30 22:49 ` Alexander Turenko 2020-11-16 22:12 ` Vladislav Shpilevoy [this message] 2020-11-25 21:32 ` Vladislav Shpilevoy 2020-11-29 21:41 ` Sergey Ostanevich 2020-11-30 21:46 ` Alexander Turenko 2020-11-30 21:01 ` Vladislav Shpilevoy 2020-12-02 10:58 ` Alexander V. Tikhonov 2020-12-02 22:18 ` Vladislav Shpilevoy
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=bc416adf-d807-860d-6f65-95556b2cef6f@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=alexander.turenko@tarantool.org \ --cc=sergos@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2] core: handle fiber cancellation for fiber.cond' \ /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