Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion include/mqtt/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
<< MQTT_ADD_VALUE(address, this)
<< "force_disconnect";

sync_shutdown(socket());
sync_force_shutdown(socket());
}

/**
Expand Down Expand Up @@ -5326,6 +5326,31 @@ class endpoint : public std::enable_shared_from_this<endpoint<Mutex, LockGuard,
connected_ = false;
}

void sync_force_shutdown(MQTT_NS::socket& s) {
MQTT_LOG("mqtt_impl", trace)
<< MQTT_ADD_VALUE(address, this)
<< "sync_force_shutdown";
if (shutdown_requested_) {
MQTT_LOG("mqtt_impl", trace)
<< MQTT_ADD_VALUE(address, this)
<< "already shutdowned";
return;
}
shutdown_requested_ = true;
mqtt_connected_ = false;

error_code ec;
MQTT_LOG("mqtt_impl", trace)
<< MQTT_ADD_VALUE(address, this)
<< "force_shutdown_and_close";
s.force_shutdown_and_close(ec);
MQTT_LOG("mqtt_impl", trace)
<< MQTT_ADD_VALUE(address, this)
<< "force_shutdown_and_close ec:"
<< ec.message();
connected_ = false;
}

void async_shutdown(MQTT_NS::socket& s, async_handler_t func) {
MQTT_LOG("mqtt_impl", trace)
<< MQTT_ADD_VALUE(address, this)
Expand Down
Loading