Fix server empty thread name (#478)
This commit is contained in:
parent
632ee31509
commit
a7019631b7
@ -41,6 +41,7 @@ namespace ix
|
|||||||
, _enablePong(kDefaultEnablePong)
|
, _enablePong(kDefaultEnablePong)
|
||||||
, _pingIntervalSecs(kDefaultPingIntervalSecs)
|
, _pingIntervalSecs(kDefaultPingIntervalSecs)
|
||||||
, _pingType(SendMessageKind::Ping)
|
, _pingType(SendMessageKind::Ping)
|
||||||
|
, _autoThreadName(true)
|
||||||
{
|
{
|
||||||
_ws.setOnCloseCallback(
|
_ws.setOnCloseCallback(
|
||||||
[this](uint16_t code, const std::string& reason, size_t wireSize, bool remote)
|
[this](uint16_t code, const std::string& reason, size_t wireSize, bool remote)
|
||||||
@ -370,7 +371,10 @@ namespace ix
|
|||||||
|
|
||||||
void WebSocket::run()
|
void WebSocket::run()
|
||||||
{
|
{
|
||||||
setThreadName(getUrl());
|
if (_autoThreadName)
|
||||||
|
{
|
||||||
|
setThreadName(getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
bool firstConnectionAttempt = true;
|
bool firstConnectionAttempt = true;
|
||||||
|
|
||||||
@ -627,4 +631,9 @@ namespace ix
|
|||||||
std::lock_guard<std::mutex> lock(_configMutex);
|
std::lock_guard<std::mutex> lock(_configMutex);
|
||||||
return _subProtocols;
|
return _subProtocols;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebSocket::setAutoThreadName(bool enabled)
|
||||||
|
{
|
||||||
|
_autoThreadName = enabled;
|
||||||
|
}
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
@ -119,6 +119,8 @@ namespace ix
|
|||||||
uint32_t getMinWaitBetweenReconnectionRetries() const;
|
uint32_t getMinWaitBetweenReconnectionRetries() const;
|
||||||
const std::vector<std::string>& getSubProtocols();
|
const std::vector<std::string>& getSubProtocols();
|
||||||
|
|
||||||
|
void setAutoThreadName(bool enabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WebSocketSendInfo sendMessage(const IXWebSocketSendData& message,
|
WebSocketSendInfo sendMessage(const IXWebSocketSendData& message,
|
||||||
SendMessageKind sendMessageKind,
|
SendMessageKind sendMessageKind,
|
||||||
@ -182,6 +184,9 @@ namespace ix
|
|||||||
// Subprotocols
|
// Subprotocols
|
||||||
std::vector<std::string> _subProtocols;
|
std::vector<std::string> _subProtocols;
|
||||||
|
|
||||||
|
// enable or disable auto set thread name
|
||||||
|
bool _autoThreadName;
|
||||||
|
|
||||||
friend class WebSocketServer;
|
friend class WebSocketServer;
|
||||||
};
|
};
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
@ -91,6 +91,9 @@ namespace ix
|
|||||||
setThreadName("Srv:ws:" + connectionState->getId());
|
setThreadName("Srv:ws:" + connectionState->getId());
|
||||||
|
|
||||||
auto webSocket = std::make_shared<WebSocket>();
|
auto webSocket = std::make_shared<WebSocket>();
|
||||||
|
|
||||||
|
webSocket->setAutoThreadName(false);
|
||||||
|
|
||||||
if (_onConnectionCallback)
|
if (_onConnectionCallback)
|
||||||
{
|
{
|
||||||
_onConnectionCallback(webSocket, connectionState);
|
_onConnectionCallback(webSocket, connectionState);
|
||||||
|
Loading…
Reference in New Issue
Block a user