Skip to content

Commit

Permalink
fix coroutine quit after client destruct (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos authored Jul 26, 2023
1 parent c1b2ee4 commit fbc35e0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion include/ylt/thirdparty/cinatra/coro_http_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,12 +1492,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 fbc35e0

Please sign in to comment.