diff --git a/include/ircd/net/socket.h b/include/ircd/net/socket.h index 209051a91..f4bb68d5a 100644 --- a/include/ircd/net/socket.h +++ b/include/ircd/net/socket.h @@ -131,9 +131,18 @@ ircd::net::socket::read_all(iov&& bufs) asio::transfer_all() }; + const auto interruption{[this] + (ctx::ctx *const &) noexcept + { + this->cancel(); + }}; + const size_t ret { - asio::async_read(ssl, std::forward(bufs), completion, yield_context{to_asio{}}) + asio::async_read(ssl, std::forward(bufs), completion, yield_context + { + to_asio{interruption} + }) }; if(!ret) @@ -152,9 +161,18 @@ template size_t ircd::net::socket::read_few(iov&& bufs) { + const auto interruption{[this] + (ctx::ctx *const &) noexcept + { + this->cancel(); + }}; + const size_t ret { - ssl.async_read_some(std::forward(bufs), yield_context{to_asio{}}) + ssl.async_read_some(std::forward(bufs), yield_context + { + to_asio{interruption} + }) }; if(!ret) @@ -215,9 +233,18 @@ ircd::net::socket::write_all(iov&& bufs) asio::transfer_all() }; + const auto interruption{[this] + (ctx::ctx *const &) noexcept + { + this->cancel(); + }}; + const size_t ret { - asio::async_write(ssl, std::forward(bufs), completion, yield_context{to_asio{}}) + asio::async_write(ssl, std::forward(bufs), completion, yield_context + { + to_asio{interruption} + }) }; out.bytes += ret; @@ -230,9 +257,18 @@ template size_t ircd::net::socket::write_few(iov&& bufs) { + const auto interruption{[this] + (ctx::ctx *const &) noexcept + { + this->cancel(); + }}; + const size_t ret { - ssl.async_write_some(std::forward(bufs), yield_context{to_asio{}}) + ssl.async_write_some(std::forward(bufs), yield_context + { + to_asio{interruption} + }) }; out.bytes += ret; diff --git a/ircd/net.cc b/ircd/net.cc index 563e91efb..d9afd5f33 100644 --- a/ircd/net.cc +++ b/ircd/net.cc @@ -1611,6 +1611,12 @@ void ircd::net::socket::wait(const wait_opts &opts) try { + const auto interruption{[this] + (ctx::ctx *const &) noexcept + { + this->cancel(); + }}; + const scope_timeout timeout { *this, opts.timeout @@ -1619,15 +1625,15 @@ try switch(opts.type) { case ready::ERROR: - sd.async_wait(wait_type::wait_error, yield_context{to_asio{}}); + sd.async_wait(wait_type::wait_error, yield_context{to_asio{interruption}}); break; case ready::WRITE: - sd.async_wait(wait_type::wait_write, yield_context{to_asio{}}); + sd.async_wait(wait_type::wait_write, yield_context{to_asio{interruption}}); break; case ready::READ: - sd.async_wait(wait_type::wait_read, yield_context{to_asio{}}); + sd.async_wait(wait_type::wait_read, yield_context{to_asio{interruption}}); break; default: