1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
7 #include <seastar/core/future.hh>
8 #include <seastar/core/future-util.hh>
10 #include "crimson/common/log.h"
11 #include "crimson/common/interruptible_future.h"
13 namespace crimson::common
{
15 class interruption
: public std::exception
18 class system_shutdown_exception final
: public interruption
{
20 const char* what() const noexcept final
{
21 return "system shutting down";
25 class actingset_changed final
: public interruption
{
27 actingset_changed(bool sp
) : still_primary(sp
) {}
28 const char* what() const noexcept final
{
29 return "acting set changed";
31 bool is_primary() const {
35 const bool still_primary
;
38 template<typename Func
, typename
... Args
>
39 inline seastar::future
<> handle_system_shutdown(Func
&& func
, Args
&&... args
)
41 return seastar::futurize_invoke(std::forward
<Func
>(func
),
42 std::forward
<Args
>(args
)...)
43 .handle_exception([](std::exception_ptr eptr
) {
44 if (*eptr
.__cxa_exception_type() ==
45 typeid(crimson::common::system_shutdown_exception
)) {
46 crimson::get_logger(ceph_subsys_osd
).debug(
47 "operation skipped, system shutdown");
48 return seastar::now();
50 std::rethrow_exception(eptr
);