From: Kefu Chai Date: Sat, 1 Oct 2022 09:43:00 +0000 (+0800) Subject: crimson/osd: use abort_source in stop_signal X-Git-Tag: v18.1.0~1046^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=728492c993f8ad94de176dc6dc4407f6f5aa8096;p=ceph.git crimson/osd: use abort_source in stop_signal before this change, `stop_signal::wait()` waits until it receives `SIGTERM` or `SIGINT`, but we also need to stop the service per the request of monitor or when a serious health condition is detected. so, an `abort_source` should allow the server to request abort by itself. also, as the single truth of stop, `stop_signal` will be able to send the message to its subscribers to abort any "blocking" calls which might prevent or delay the stop process. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/osd/stop_signal.h b/src/crimson/osd/stop_signal.h index ccc340b13868..434156f1fb57 100644 --- a/src/crimson/osd/stop_signal.h +++ b/src/crimson/osd/stop_signal.h @@ -22,7 +22,7 @@ #pragma once -#include +#include #include #include @@ -49,14 +49,15 @@ namespace seastar_apps_lib { /// }); /// \endcode class stop_signal { - bool _caught = false; seastar::condition_variable _cond; + seastar::abort_source _abort_source; + private: void signaled() { - if (_caught) { + if (stopping()) { return; } - _caught = true; + _abort_source.request_abort(); _cond.broadcast(); } public: @@ -70,10 +71,13 @@ public: seastar::engine().handle_signal(SIGTERM, [] {}); } seastar::future<> wait() { - return _cond.wait([this] { return _caught; }); + return _cond.wait([this] { return _abort_source.abort_requested(); }); } bool stopping() const { - return _caught; + return _abort_source.abort_requested(); + } + auto& abort_source() { + return _abort_source; } }; }