Fix hanging of WebSocket::stop() waiting for its thread to join (#481)
This might happen in some special cases where WebSocketTransport::sendOnSocket() fails, closes the socket, and set the ready state to CLOSED, but WebSocket::run() stills wait the interrupt event to happen. Possibly related to #474
This commit is contained in:
parent
28832f8732
commit
ef57e3a2b1
@ -1174,7 +1174,22 @@ namespace ix
|
||||
{
|
||||
_requestInitCancellation = true;
|
||||
|
||||
if (_readyState == ReadyState::CLOSING || _readyState == ReadyState::CLOSED) return;
|
||||
if (_readyState == ReadyState::CLOSING || _readyState == ReadyState::CLOSED)
|
||||
{
|
||||
// Wake up the socket polling thread, as
|
||||
// Socket::isReadyToRead() might be still waiting the
|
||||
// interrupt event to happen.
|
||||
bool wakeUpPoll = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_socketMutex);
|
||||
wakeUpPoll = (_socket && _socket->isWakeUpFromPollSupported());
|
||||
}
|
||||
if (wakeUpPoll)
|
||||
{
|
||||
wakeUpFromPoll(SelectInterrupt::kCloseRequest);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (closeWireSize == 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user