From: root Date: Thu, 8 Sep 2022 16:21:50 +0000 (-0400) Subject: rgw: Drain async_processor request queue during shutdown X-Git-Tag: v16.2.15~127^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F53472%2Fhead;p=ceph.git 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) --- 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;