From 4d224de6e50c6ad9a64fdc44801d27a156f6cfdd Mon Sep 17 00:00:00 2001 From: Lee *!* Clagett Date: Tue, 24 Aug 2021 19:25:45 -0400 Subject: Quicker resource cleanup on p2p socks timeout --- src/net/socks.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/net/socks.h') diff --git a/src/net/socks.h b/src/net/socks.h index 739c972ab..506b53195 100644 --- a/src/net/socks.h +++ b/src/net/socks.h @@ -201,6 +201,13 @@ namespace socks std::shared_ptr self_; void operator()(boost::system::error_code error = boost::system::error_code{}); }; + + //! Calls `async_close` on `self` at destruction. NOP if `nullptr`. + struct close_on_exit + { + std::shared_ptr self; + ~close_on_exit() { async_close{std::move(self)}(); } + }; }; template -- cgit v1.2.3