From 93f31b70dfdd32a13ec3b170cccb89a153a14ff5 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 8 Sep 2022 12:21:50 -0400 Subject: [PATCH] rgw: Drain async_processor request queue during shutdown Drain outstanding requests from the async_processor before stopping the sync threads to avoid any use-after-free of their local variables. Fixes: https://tracker.ceph.com/issues/49666 Signed-off-by: Soumya Koduri (cherry picked from commit 9b451763ff583f25c821aecf3446884c0fb95273) --- src/rgw/rgw_rados.cc | 6 ++++++ src/rgw/services/svc_rados.cc | 7 +++++++ src/rgw/services/svc_rados.h | 1 + 3 files changed, 14 insertions(+) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 4b1cb1c45e2a..349b41c7e8b5 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1028,6 +1028,12 @@ bool RGWIndexCompletionManager::handle_completion(completion_t cb, complete_op_d void RGWRados::finalize() { + /* Before joining any sync threads, drain outstanding requests & + * mark the async_processor as going_down() */ + if (svc.rados) { + svc.rados->stop_processor(); + } + if (run_sync_thread) { std::lock_guard l{meta_sync_thread_lock}; meta_sync_processor_thread->stop(); diff --git a/src/rgw/services/svc_rados.cc b/src/rgw/services/svc_rados.cc index 32a6b3a3e39a..5949917e9d3b 100644 --- a/src/rgw/services/svc_rados.cc +++ b/src/rgw/services/svc_rados.cc @@ -45,6 +45,13 @@ void RGWSI_RADOS::shutdown() } } +void RGWSI_RADOS::stop_processor() +{ + if (async_processor) { + async_processor->stop(); + } +} + librados::Rados* RGWSI_RADOS::get_rados_handle() { return &rados; diff --git a/src/rgw/services/svc_rados.h b/src/rgw/services/svc_rados.h index d3fa393140b8..0a6e262ece49 100644 --- a/src/rgw/services/svc_rados.h +++ b/src/rgw/services/svc_rados.h @@ -66,6 +66,7 @@ public: void init() {} void shutdown() override; + void stop_processor(); uint64_t instance_id(); bool check_secure_mon_conn() const; -- 2.47.3