Skip to content

Commit

Permalink
Fix close on send.
Browse files Browse the repository at this point in the history
  • Loading branch information
redboltz committed Nov 19, 2024
1 parent 3abae56 commit eda74b8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions include/async_mqtt/impl/endpoint_send.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ send_op {
using events_it_type = typename events_type::iterator;
std::shared_ptr<events_type> events = nullptr;
events_it_type it = events_it_type{};
enum { dispatch, write, sent, complete } state = dispatch;
enum { dispatch, write, sent, close, complete } state = dispatch;

template <typename Self>
bool process_one_event(
Expand Down Expand Up @@ -102,10 +102,9 @@ send_op {
},
[&](event_close) {
std::cout << __FILE__ << ":" << __LINE__ << ":" << &a_ep << std::endl;
state = complete;
auto ep_copy{ep};
async_close(
force_move(ep_copy),
state = close;
as::post(
a_ep.get_executor(),
force_move(self)
);
return false;
Expand Down Expand Up @@ -173,6 +172,14 @@ send_op {
force_move(self)
);
} break;
case close: {
state = complete;
auto ep_copy{ep};
async_close(
force_move(ep_copy),
force_move(self)
);
} break;
case complete: {
if (decided_error) {
std::cout << __FILE__ << ":" << __LINE__ << ":" << &a_ep << std::endl;
Expand Down

0 comments on commit eda74b8

Please sign in to comment.