Skip to content

Commit

Permalink
fix coroutine quit after destruct (qicosmos#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos authored Jul 26, 2023
1 parent 93bd6b3 commit 0cc289a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion include/cinatra/coro_http_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1513,12 +1513,21 @@ class coro_http_client {

websocket ws{};
while (true) {
std::weak_ptr socket = socket_;
if (auto [ec, _] = co_await async_read(read_buf_, header_size); ec) {
data.net_err = ec;
data.status = 404;
close_socket(*socket_);
auto sock = socket.lock();
if (!sock) {
co_return;
}
if (!sock->has_closed_) {
close_socket(*sock);
}

if (on_ws_msg_)
on_ws_msg_(data);

co_return;
}

Expand Down

0 comments on commit 0cc289a

Please sign in to comment.