drogonframework / drogonframework/drogon

WebSocketClientImpl::stop also need to run the loop thread

Open
#1,337 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

If I call stop on another thread, It will be core dump,because `onRecvMessage `will use `websockConnPtr_`
```
void WebSocketClientImpl::stop()
{
stop_ = true;
if (websockConnPtr_)
{
websockConnPtr_->shutdown();
websockConnPtr_.reset();
}
tcpClientPtr_.reset();
}

tcpClientPtr_->setMessageCallback(
[weakPtr](const trantor::TcpConnectionPtr &connPtr,
trantor::MsgBuffer *msg) {
auto thisPtr = weakPtr.lock();
if (thisPtr)
{
thisPtr->onRecvMessage(connPtr, msg);
}
});

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.