fix websocket dead lock

This commit is contained in:
andyque 2015-01-16 18:43:57 +08:00
parent b556f970b0
commit fcfcb4fd71
1 changed files with 6 additions and 4 deletions

View File

@ -540,7 +540,8 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
size_t remaining = data->len - data->issued;
size_t n = std::min(remaining, c_bufferSize );
CCLOG("[websocket:send] total: %d, sent: %d, remaining: %d, buffer size: %d", static_cast<int>(data->len), static_cast<int>(data->issued), static_cast<int>(remaining), static_cast<int>(n));
//fixme: the log is not thread safe
// CCLOG("[websocket:send] total: %d, sent: %d, remaining: %d, buffer size: %d", static_cast<int>(data->len), static_cast<int>(data->issued), static_cast<int>(remaining), static_cast<int>(n));
unsigned char* buf = new unsigned char[LWS_SEND_BUFFER_PRE_PADDING + n + LWS_SEND_BUFFER_POST_PADDING];
@ -570,7 +571,8 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
}
bytesWrite = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], n, (libwebsocket_write_protocol)writeProtocol);
CCLOG("[websocket:send] bytesWrite => %d", bytesWrite);
//fixme: the log is not thread safe
// CCLOG("[websocket:send] bytesWrite => %d", bytesWrite);
// Buffer overrun?
if (bytesWrite < 0)
@ -603,8 +605,8 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
case LWS_CALLBACK_CLOSED:
{
CCLOG("%s", "connection closing..");
//fixme: the log is not thread safe
// CCLOG("%s", "connection closing..");
_wsHelper->quitSubThread();