aboutsummaryrefslogtreecommitdiff
path: root/src/net/socks.h
diff options
context:
space:
mode:
authorLee *!* Clagett <code@leeclagett.com>2021-08-24 19:25:45 -0400
committerLee Clagett <code@leeclagett.com>2021-07-29 08:54:13 +0000
commit2a8a51129f7fa916dac6fb721b774784f42b360d (patch)
treedebbeb38457cf870f43b6c8858e78e283f026389 /src/net/socks.h
parentMerge pull request #7881 (diff)
downloadmonero-2a8a51129f7fa916dac6fb721b774784f42b360d.tar.xz
Quicker resource cleanup on p2p socks timeout
Diffstat (limited to 'src/net/socks.h')
-rw-r--r--src/net/socks.h7
1 files changed, 7 insertions, 0 deletions
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<client> 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<client> self;
+ ~close_on_exit() { async_close{std::move(self)}(); }
+ };
};
template<typename Handler>