drogon icon indicating copy to clipboard operation
drogon copied to clipboard

WebSocketClientImpl::stop also need to run the loop thread

Open nqf opened this issue 3 years ago • 0 comments

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);
            }
        });

nqf avatar Aug 01 '22 00:08 nqf