* [tarantool-patches] [PATCH] Do not recycle a fiber if it is canceled
@ 2018-07-13 11:47 Georgy Kirichenko
2018-07-16 10:20 ` Vladimir Davydov
2018-07-16 14:57 ` [tarantool-patches] " Kirill Yukhin
0 siblings, 2 replies; 3+ messages in thread
From: Georgy Kirichenko @ 2018-07-13 11:47 UTC (permalink / raw)
To: tarantool-patches; +Cc: Georgy Kirichenko
If a fiber pool reuses already canceled fiber then the fiber reports an
error for any next request. Now canceled fiber returns and fiber pool
creates a new one.
Fixes #3527
---
Issue: https://github.com/tarantool/tarantool/3527
Branch:
https://github.com/tarantool/tarantool/tree/gh-3527-fiber-is-cancelled-in-pool
src/fiber_pool.c | 6 +++---
test/app/fiber.result | 18 ++++++++++++++++++
test/app/fiber.test.lua | 6 ++++++
3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/src/fiber_pool.c b/src/fiber_pool.c
index aa8b19510..d132789d3 100644
--- a/src/fiber_pool.c
+++ b/src/fiber_pool.c
@@ -46,7 +46,7 @@ fiber_pool_f(va_list ap)
pool->size++;
restart:
msg = NULL;
- while (! stailq_empty(output)) {
+ while (!stailq_empty(output) && !fiber_is_cancelled(fiber())) {
msg = stailq_shift_entry(output, struct cmsg, fifo);
if (f->caller == &cord->sched && ! stailq_empty(output) &&
@@ -64,8 +64,8 @@ restart:
cmsg_deliver(msg);
}
/** Put the current fiber into a fiber cache. */
- if (msg != NULL ||
- ev_monotonic_now(loop) - last_active_at < pool->idle_timeout) {
+ if (!fiber_is_cancelled(fiber()) && (msg != NULL ||
+ ev_monotonic_now(loop) - last_active_at < pool->idle_timeout)) {
if (msg != NULL)
last_active_at = ev_monotonic_now(loop);
/*
diff --git a/test/app/fiber.result b/test/app/fiber.result
index 0253fe08f..9eedc6e95 100644
--- a/test/app/fiber.result
+++ b/test/app/fiber.result
@@ -1209,3 +1209,21 @@ test_run:cmd("clear filter")
---
- true
...
+box.schema.user.grant('guest', 'execute', 'universe')
+---
+...
+con = require('net.box').connect(box.cfg.listen)
+---
+...
+pcall(con.eval, con, 'fiber.cancel(fiber.self())')
+---
+- false
+- fiber is cancelled
+...
+con:eval('fiber.sleep(0) return "Ok"')
+---
+- Ok
+...
+box.schema.user.revoke('guest', 'execute', 'universe')
+---
+...
diff --git a/test/app/fiber.test.lua b/test/app/fiber.test.lua
index c06a41779..d59cf64ed 100644
--- a/test/app/fiber.test.lua
+++ b/test/app/fiber.test.lua
@@ -505,3 +505,9 @@ l1 = nil
-- cleanup
test_run:cmd("clear filter")
+
+box.schema.user.grant('guest', 'execute', 'universe')
+con = require('net.box').connect(box.cfg.listen)
+pcall(con.eval, con, 'fiber.cancel(fiber.self())')
+con:eval('fiber.sleep(0) return "Ok"')
+box.schema.user.revoke('guest', 'execute', 'universe')
--
2.18.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [tarantool-patches] [PATCH] Do not recycle a fiber if it is canceled
2018-07-13 11:47 [tarantool-patches] [PATCH] Do not recycle a fiber if it is canceled Georgy Kirichenko
@ 2018-07-16 10:20 ` Vladimir Davydov
2018-07-16 14:57 ` [tarantool-patches] " Kirill Yukhin
1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Davydov @ 2018-07-16 10:20 UTC (permalink / raw)
To: Georgy Kirichenko; +Cc: tarantool-patches
On Fri, Jul 13, 2018 at 02:47:41PM +0300, Georgy Kirichenko wrote:
> If a fiber pool reuses already canceled fiber then the fiber reports an
> error for any next request. Now canceled fiber returns and fiber pool
> creates a new one.
>
> Fixes #3527
> ---
> Issue: https://github.com/tarantool/tarantool/3527
> Branch:
> https://github.com/tarantool/tarantool/tree/gh-3527-fiber-is-cancelled-in-pool
>
>
> src/fiber_pool.c | 6 +++---
> test/app/fiber.result | 18 ++++++++++++++++++
> test/app/fiber.test.lua | 6 ++++++
> 3 files changed, 27 insertions(+), 3 deletions(-)
Looks good to me.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tarantool-patches] Re: [PATCH] Do not recycle a fiber if it is canceled
2018-07-13 11:47 [tarantool-patches] [PATCH] Do not recycle a fiber if it is canceled Georgy Kirichenko
2018-07-16 10:20 ` Vladimir Davydov
@ 2018-07-16 14:57 ` Kirill Yukhin
1 sibling, 0 replies; 3+ messages in thread
From: Kirill Yukhin @ 2018-07-16 14:57 UTC (permalink / raw)
To: tarantool-patches; +Cc: Georgy Kirichenko
Hello.
On 13 июл 14:47, Georgy Kirichenko wrote:
> If a fiber pool reuses already canceled fiber then the fiber reports an
> error for any next request. Now canceled fiber returns and fiber pool
> creates a new one.
>
> Fixes #3527
> ---
> Issue: https://github.com/tarantool/tarantool/3527
> Branch:
> https://github.com/tarantool/tarantool/tree/gh-3527-fiber-is-cancelled-in-pool
I've checked your patch into 1-9 branch.
--
Regards, Kirill Yukhin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-16 14:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-13 11:47 [tarantool-patches] [PATCH] Do not recycle a fiber if it is canceled Georgy Kirichenko
2018-07-16 10:20 ` Vladimir Davydov
2018-07-16 14:57 ` [tarantool-patches] " Kirill Yukhin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox