From 057aac4516b3af9c6c515fcfb6df7df4cc3bc393 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 20 Mar 2018 11:47:39 -0700 Subject: [PATCH] rgw: coroutines: cancel stacks on teardown If we don't cancel stacks, ops might not be destructed, so ops callbacks could still be active. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_coroutine.cc | 11 ++++++++++- src/rgw/rgw_coroutine.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_coroutine.cc b/src/rgw/rgw_coroutine.cc index 9a566ecb1a6a3..1980f372eac12 100644 --- a/src/rgw/rgw_coroutine.cc +++ b/src/rgw/rgw_coroutine.cc @@ -347,6 +347,15 @@ int RGWCoroutinesStack::unwind(int retcode) return 0; } +void RGWCoroutinesStack::cancel() +{ + while (!ops.empty()) { + RGWCoroutine *op = *pos; + unwind(-ECANCELED); + op->put(); + } + put(); +} bool RGWCoroutinesStack::collect(RGWCoroutine *op, int *ret, RGWCoroutinesStack *skip_stack) /* returns true if needs to be called again */ { @@ -730,7 +739,7 @@ next: for (auto stack : context_stacks) { ldout(cct, 20) << "clearing stack on run() exit: stack=" << (void *)stack << " nref=" << stack->get_nref() << dendl; - stack->put(); + stack->cancel(); } run_contexts.erase(run_context); lock.unlock(); diff --git a/src/rgw/rgw_coroutine.h b/src/rgw/rgw_coroutine.h index d61b40aae9ba5..7212a4fc84a11 100644 --- a/src/rgw/rgw_coroutine.h +++ b/src/rgw/rgw_coroutine.h @@ -476,6 +476,8 @@ public: bool collect(int *ret, RGWCoroutinesStack *skip_stack); /* returns true if needs to be called again */ + void cancel(); + RGWAioCompletionNotifier *create_completion_notifier(); RGWCompletionManager *get_completion_mgr(); -- 2.39.5