(websocket) fix data race accessing _socket object without mutex protection when calling wakeUpFromPoll in WebSocketTransport.cpp
This commit is contained in:
parent
18164c0c38
commit
0fffb1e894
@ -1,6 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [9.1.1] - 2020-03-26
|
||||||
|
|
||||||
|
(websocket) fix data race accessing _socket object without mutex protection when calling wakeUpFromPoll in WebSocketTransport.cpp
|
||||||
|
|
||||||
## [9.1.0] - 2020-03-26
|
## [9.1.0] - 2020-03-26
|
||||||
|
|
||||||
(ixcobra) add explicit event types for handshake, authentication and subscription failure, and handle those by exiting in ws_cobra_subcribe and friends
|
(ixcobra) add explicit event types for handshake, authentication and subscription failure, and handle those by exiting in ws_cobra_subcribe and friends
|
||||||
|
@ -625,7 +625,7 @@ namespace ix
|
|||||||
// send back the CLOSE frame
|
// send back the CLOSE frame
|
||||||
sendCloseFrame(code, reason);
|
sendCloseFrame(code, reason);
|
||||||
|
|
||||||
_socket->wakeUpFromPoll(Socket::kCloseRequest);
|
wakeUpFromPoll(Socket::kCloseRequest);
|
||||||
|
|
||||||
bool remote = true;
|
bool remote = true;
|
||||||
closeSocketAndSwitchToClosedState(code, reason, _rxbuf.size(), remote);
|
closeSocketAndSwitchToClosedState(code, reason, _rxbuf.size(), remote);
|
||||||
@ -845,7 +845,7 @@ namespace ix
|
|||||||
// Request to flush the send buffer on the background thread if it isn't empty
|
// Request to flush the send buffer on the background thread if it isn't empty
|
||||||
if (!isSendBufferEmpty())
|
if (!isSendBufferEmpty())
|
||||||
{
|
{
|
||||||
_socket->wakeUpFromPoll(Socket::kSendRequest);
|
wakeUpFromPoll(Socket::kSendRequest);
|
||||||
|
|
||||||
// FIXME: we should have a timeout when sending large messages: see #131
|
// FIXME: we should have a timeout when sending large messages: see #131
|
||||||
if (_blockingSend && !flushSendBuffer())
|
if (_blockingSend && !flushSendBuffer())
|
||||||
@ -1063,6 +1063,12 @@ namespace ix
|
|||||||
_socket->close();
|
_socket->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WebSocketTransport::wakeUpFromPoll(uint64_t wakeUpCode)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(_socketMutex);
|
||||||
|
return _socket->wakeUpFromPoll(wakeUpCode);
|
||||||
|
}
|
||||||
|
|
||||||
void WebSocketTransport::closeSocketAndSwitchToClosedState(uint16_t code,
|
void WebSocketTransport::closeSocketAndSwitchToClosedState(uint16_t code,
|
||||||
const std::string& reason,
|
const std::string& reason,
|
||||||
size_t closeWireSize,
|
size_t closeWireSize,
|
||||||
@ -1110,8 +1116,9 @@ namespace ix
|
|||||||
setReadyState(ReadyState::CLOSING);
|
setReadyState(ReadyState::CLOSING);
|
||||||
|
|
||||||
sendCloseFrame(code, reason);
|
sendCloseFrame(code, reason);
|
||||||
|
|
||||||
// wake up the poll, but do not close yet
|
// wake up the poll, but do not close yet
|
||||||
_socket->wakeUpFromPoll(Socket::kSendRequest);
|
wakeUpFromPoll(Socket::kSendRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t WebSocketTransport::bufferedAmount() const
|
size_t WebSocketTransport::bufferedAmount() const
|
||||||
|
@ -229,6 +229,8 @@ namespace ix
|
|||||||
size_t closeWireSize,
|
size_t closeWireSize,
|
||||||
bool remote);
|
bool remote);
|
||||||
|
|
||||||
|
bool wakeUpFromPoll(uint64_t wakeUpCode);
|
||||||
|
|
||||||
bool flushSendBuffer();
|
bool flushSendBuffer();
|
||||||
bool sendOnSocket();
|
bool sendOnSocket();
|
||||||
bool receiveFromSocket();
|
bool receiveFromSocket();
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "9.1.0"
|
#define IX_WEBSOCKET_VERSION "9.1.1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user