From dd0bb8bfbdafdd906f8af3b5eccf4619bdc6f2f6 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Wed, 30 Sep 2020 15:13:04 -0400 Subject: [PATCH] rgw_file: avoid long-ish delay on shutdown Normal shutdown was likely to be delayed a substantial fraction of rgw_nfs_namespace_expire_secs due to an ill-advised use of this_thread::sleep_for. Fixes: https://tracker.ceph.com/issues/47710 Signed-off-by: Matt Benjamin (cherry picked from commit 805f74956489e3158437acc1c3c12f267221843e) --- src/rgw/librgw.cc | 2 +- src/rgw/rgw_lib_frontend.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rgw/librgw.cc b/src/rgw/librgw.cc index 5e8578f0baf..1dd889829e0 100644 --- a/src/rgw/librgw.cc +++ b/src/rgw/librgw.cc @@ -128,8 +128,8 @@ namespace rgw { if (cur_gen != gen) goto restart; /* invalidated */ } + cv.wait_for(uniq, std::chrono::seconds(delay_s)); uniq.unlock(); - std::this_thread::sleep_for(std::chrono::seconds(delay_s)); } } diff --git a/src/rgw/rgw_lib_frontend.h b/src/rgw/rgw_lib_frontend.h index 7b1b929005c..ec4ede04047 100644 --- a/src/rgw/rgw_lib_frontend.h +++ b/src/rgw/rgw_lib_frontend.h @@ -14,6 +14,7 @@ namespace rgw { class RGWLibProcess : public RGWProcess { RGWAccessKey access_key; std::mutex mtx; + std::condition_variable cv; int gen; bool shutdown; @@ -36,6 +37,7 @@ namespace rgw { for (const auto& fs: mounted_fs) { fs.second->stop(); } + cv.notify_all(); } void register_fs(RGWLibFS* fs) { -- 2.47.3