From bc299e56e46e5712ebe91492cf683b51fe0db125 Mon Sep 17 00:00:00 2001 From: Daniel Gryniewicz Date: Thu, 28 Jul 2016 14:39:07 -0400 Subject: [PATCH] Clean up lifecycle thread Make sure that the lifecycle thread is terminated and all memory is cleaned up on shutdown. Signed-off-by: Daniel Gryniewicz --- src/rgw/rgw_lc.cc | 3 ++- src/rgw/rgw_lc.h | 1 + src/rgw/rgw_rados.cc | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index 0e8df5ed333..8876f6330ce 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -474,6 +474,7 @@ void RGWLC::start_processor() void RGWLC::stop_processor() { + down_flag.set(1); if (worker) { worker->stop(); worker->join(); @@ -490,7 +491,7 @@ void RGWLC::LCWorker::stop() bool RGWLC::going_down() { - return false; + return (down_flag.read() != 0); } bool RGWLC::LCWorker::should_work(utime_t& now) diff --git a/src/rgw/rgw_lc.h b/src/rgw/rgw_lc.h index 0c4126c1ece..30d2f2b0223 100644 --- a/src/rgw/rgw_lc.h +++ b/src/rgw/rgw_lc.h @@ -179,6 +179,7 @@ class RGWLC { RGWRados *store; int max_objs; string *obj_names; + atomic_t down_flag; class LCWorker : public Thread { CephContext *cct; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index f25592a7198..3e0a55b0449 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -3176,6 +3176,12 @@ void RGWRados::finalize() delete gc; gc = NULL; + if (use_lc_thread) { + lc->stop_processor(); + } + delete lc; + lc = NULL; + delete obj_expirer; obj_expirer = NULL;