Gracefully shutdown Websocket and TLS streams

Summary:
Resolves #18
Ref T15241

Reviewers: ivica

Reviewed By: ivica

Subscribers: korina, miljen

Maniphest Tasks: T15241

Differential Revision: https://repo.mireo.local/D33395
This commit is contained in:
Bruno Iljazovic committed 2025-01-30 18:18:05 +01:00
1 parent 4df9dbbb07
commit 8b41f0dd4d
23 files changed
+460 -59

No files matched your search

@@ -95,7 +95,6 @@ public:
void close() {
error_code ec;
detail::lowest_layer(*_stream_ptr).shutdown(asio::ip::tcp::socket::shutdown_both, ec);
detail::lowest_layer(*_stream_ptr).close(ec);
}
+1
View File
@@ -224,6 +224,7 @@ public:
auto initiation = [this](
auto handler, const MutableBuffer& buffer
) {
_pending_read.complete(_ex, asio::error::operation_aborted, 0);
_pending_read = pending_read(buffer, std::move(handler));
complete_read();
};
+4 -12
View File
@@ -79,10 +79,6 @@ public:
_test_broker = nullptr;
}
void shutdown(asio::ip::tcp::socket::shutdown_type, error_code& ec) {
ec = {};
}
void connect(const endpoint_type& ep, error_code& ec) {
ec = {};
_remote_ep = ep;
@@ -165,8 +161,6 @@ public:
}
void operator()(on_read, error_code ec, size_t bytes_read) {
if (ec)
_stream_impl->disconnect();
complete(ec, bytes_read);
}
@@ -223,8 +217,6 @@ public:
}
void operator()(on_write, error_code ec, size_t bytes_written) {
if (ec)
_stream_impl->disconnect();
complete(ec, bytes_written);
}
@@ -300,10 +292,6 @@ public:
return _impl->is_connected();
}
void shutdown(asio::ip::tcp::socket::shutdown_type st, error_code& ec) {
return _impl->shutdown(st, ec);
}
endpoint_type remote_endpoint(error_code& ec) {
return _impl->remote_endpoint(ec);
}
@@ -368,6 +356,10 @@ public:
};
template <typename ShutdownHandler>
void async_shutdown(test_stream&, ShutdownHandler&& handler) {
return std::move(handler)(error_code {});
}
} // end namespace boost::mqtt5::test