diff options
author | Lee *!* Clagett <code@leeclagett.com> | 2021-08-24 19:25:45 -0400 |
---|---|---|
committer | Lee Clagett <code@leeclagett.com> | 2021-09-27 13:47:51 +0000 |
commit | 4d224de6e50c6ad9a64fdc44801d27a156f6cfdd (patch) | |
tree | e46d6a286775aa30223450b6a42c58fd40bad0e7 /src/net/socks.h | |
parent | Merge pull request #7964 (diff) | |
download | monero-4d224de6e50c6ad9a64fdc44801d27a156f6cfdd.tar.xz |
Quicker resource cleanup on p2p socks timeout
Diffstat (limited to '')
-rw-r--r-- | src/net/socks.h | 7 |
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> |