Skip to content

Commit

Permalink
fix: active close connection no need close all
Browse files Browse the repository at this point in the history
  • Loading branch information
helintongh committed Oct 13, 2023
1 parent efe0709 commit 895e5af
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/cinatra/connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ class connection : public base_connection,
std::string close_msg = ws_.format_close_payload(
close_code::normal, close_reason.data(), close_reason.size());
auto header = ws_.format_header(close_msg.length(), opcode::close);
is_active_close_ = true;
send_msg(std::move(header), std::move(close_msg));
}
}
Expand Down Expand Up @@ -1435,7 +1436,7 @@ class connection : public base_connection,
send_failed_cb_(ec);
req_.set_state(data_proc_state::data_error);
call_back();
if (req_.get_websocket_state())
if (!is_active_close_)
close();
}
});
Expand Down Expand Up @@ -1495,6 +1496,8 @@ class connection : public base_connection,

QuitCallback quit_callback_ = nullptr;
uint64_t conn_id_ = 0;

bool is_active_close_ = false;
};

inline constexpr data_proc_state ws_open = data_proc_state::data_begin;
Expand Down

0 comments on commit 895e5af

Please sign in to comment.