mirror of
https://github.com/boostorg/mqtt5.git
synced 2025-11-06 10:51:37 +01:00
Re-create client_service after stopping client's runloop and let it destroy asynchronously
Summary: related to T11798, #5 Reviewers: ivica Reviewed By: ivica Subscribers: miljen, iljazovic Differential Revision: https://repo.mireo.local/D27882
This commit is contained in:
@@ -36,10 +36,15 @@ class stream_context<
|
||||
using tls_context_type = TlsContext;
|
||||
|
||||
mqtt_ctx _mqtt_context;
|
||||
tls_context_type _tls_context;
|
||||
std::shared_ptr<tls_context_type> _tls_context_ptr;
|
||||
|
||||
public:
|
||||
explicit stream_context(TlsContext tls_context) :
|
||||
_tls_context(std::move(tls_context))
|
||||
_tls_context_ptr(std::make_shared<tls_context_type>(std::move(tls_context)))
|
||||
{}
|
||||
|
||||
stream_context(const stream_context& other) :
|
||||
_mqtt_context(other._mqtt_context), _tls_context_ptr(other._tls_context_ptr)
|
||||
{}
|
||||
|
||||
auto& mqtt_context() {
|
||||
@@ -51,7 +56,7 @@ public:
|
||||
}
|
||||
|
||||
auto& tls_context() {
|
||||
return _tls_context;
|
||||
return *_tls_context_ptr;
|
||||
}
|
||||
|
||||
auto& session_state() {
|
||||
@@ -115,6 +120,9 @@ class stream_context<
|
||||
mqtt_ctx _mqtt_context;
|
||||
public:
|
||||
explicit stream_context(std::monostate) {}
|
||||
stream_context(const stream_context& other) :
|
||||
_mqtt_context(other._mqtt_context)
|
||||
{}
|
||||
|
||||
auto& mqtt_context() {
|
||||
return _mqtt_context;
|
||||
@@ -231,6 +239,17 @@ private:
|
||||
|
||||
asio::any_completion_handler<void(error_code)> _run_handler;
|
||||
|
||||
client_service(const client_service& other) :
|
||||
_executor(other._executor), _stream_context(other._stream_context),
|
||||
_stream(_executor, _stream_context),
|
||||
_replies(_executor),
|
||||
_async_sender(*this),
|
||||
_active_span(_read_buff.cend(), _read_buff.cend()),
|
||||
_rec_channel(_executor, std::numeric_limits<size_t>::max())
|
||||
{
|
||||
_stream.clone_endpoints(other._stream);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
client_service(
|
||||
@@ -251,6 +270,10 @@ public:
|
||||
return _executor;
|
||||
}
|
||||
|
||||
auto dup() const {
|
||||
return std::shared_ptr<client_service>(new client_service(*this));
|
||||
}
|
||||
|
||||
template <
|
||||
typename Ctx = TlsContext,
|
||||
std::enable_if_t<!std::is_same_v<Ctx, std::monostate>, bool> = true
|
||||
|
||||
Reference in New Issue
Block a user