From 9106e8ad3121a503bf49a7334367849756bd1291 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 7 Mar 2016 15:25:39 -0800 Subject: [PATCH] rgw: reorder RGWRados::finalize() first stop all sync threads, then delete them. Might be referencing each other. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_http_client.cc | 1 + src/rgw/rgw_rados.cc | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index 40fdb0cae5e78..1046a91b0cfc0 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -558,6 +558,7 @@ void RGWHTTPManager::stop() { if (is_threaded) { going_down.set(1); + signal_thread(); reqs_thread->join(); delete reqs_thread; } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index f0e15226b5ad8..8f45ad7e91dee 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -3065,20 +3065,25 @@ int RGWRados::get_max_chunk_size(rgw_bucket& bucket, uint64_t *max_chunk_size) void RGWRados::finalize() { + if (run_sync_thread) { + Mutex::Locker l(meta_sync_thread_lock); + meta_sync_processor_thread->stop(); + + Mutex::Locker dl(data_sync_thread_lock); + for (auto iter : data_sync_processor_threads) { + RGWDataSyncProcessorThread *thread = iter.second; + thread->stop(); + } + } if (async_rados) { async_rados->stop(); } if (run_sync_thread) { - Mutex::Locker l(meta_sync_thread_lock); - meta_sync_processor_thread->stop(); delete meta_sync_processor_thread; meta_sync_processor_thread = NULL; - Mutex::Locker dl(data_sync_thread_lock); - map::iterator iter = data_sync_processor_threads.begin(); - for (; iter != data_sync_processor_threads.end(); ++iter) { - RGWDataSyncProcessorThread *thread = iter->second; - thread->stop(); + for (auto iter : data_sync_processor_threads) { + RGWDataSyncProcessorThread *thread = iter.second; delete thread; } data_sync_processor_threads.clear(); -- 2.39.5