Skip to content

Commit e57bb34

Browse files
committed
fix(requests): correct transport lifetime handling
1 parent 0d0c007 commit e57bb34

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/transport/HttpsTransport.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,13 @@ namespace vix::requests::transport
665665
struct HttpsTransport::State
666666
{
667667
vix::async::core::io_context *ctx;
668+
// Keep Asio alive while a pooled TLS stream still owns an executor.
669+
std::shared_ptr<vix::async::net::detail::asio_net_service> net;
668670
asio::ssl::context tls{asio::ssl::context::tls_client};
669671
ssl_stream stream;
670672

671673
explicit State(vix::async::core::io_context &value)
672-
: ctx(&value), stream(value.net().asio_ctx(), tls) {}
674+
: ctx(&value), net(value.net_shared()), stream(net->asio_ctx(), tls) {}
673675
};
674676

675677
HttpsTransport::HttpsTransport() = default;

‎src/transport/TcpTransport.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ namespace vix::requests::transport
391391
core::task<void> TcpTransport::connect(
392392
core::io_context &ctx,
393393
net::tcp_stream &stream,
394-
const Url &url,
394+
Url url,
395395
const Timeout &timeout) const
396396
{
397397
core::cancel_source source;

‎src/transport/TcpTransport.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ namespace vix::requests::transport
115115
[[nodiscard]] vix::async::core::task<void> connect(
116116
vix::async::core::io_context &ctx,
117117
vix::async::net::tcp_stream &stream,
118-
const Url &url,
118+
Url url,
119119
const Timeout &timeout) const;
120120

121121
/**

0 commit comments

Comments
 (0)