While using Timeout, don't unnecessarily keep the strand alive via smart pointer

This commit is contained in:
Alexander A. Klimov 2024-11-28 16:31:18 +01:00
parent 8cdbea303b
commit d2285bcf0e
2 changed files with 2 additions and 4 deletions

View File

@ -514,13 +514,11 @@ void RedisConnection::Handshake(StreamPtr& strm, boost::asio::yield_context& yc)
template<class StreamPtr>
Timeout::Ptr RedisConnection::MakeTimeout(StreamPtr& stream)
{
Ptr keepAlive (this);
return new Timeout(
m_Strand.context(),
m_Strand,
boost::posix_time::microseconds(intmax_t(m_ConnectTimeout * 1000000)),
[keepAlive, stream] {
[stream] {
boost::system::error_code ec;
stream->lowest_layer().cancel(ec);
}

View File

@ -687,7 +687,7 @@ void ApiListener::NewClientHandlerInternal(
strand->context(),
*strand,
boost::posix_time::microseconds(intmax_t(Configuration::TlsHandshakeTimeout * 1000000)),
[strand, client] {
[client] {
boost::system::error_code ec;
client->lowest_layer().cancel(ec);
}