in nlsCppSdk/transport/connectNode.cpp [870:984]
void ConnectNode::closeStatusConnectNodeForConnectedPool() {
bool lock_ret = true;
MUTEX_TRY_LOCK(_mtxCloseNode, 2000, lock_ret);
if (!lock_ret) {
LOG_ERROR(
"Node(%p) closeStatusConnectNodeForConnectedPool, deadlock has "
"occurred",
this);
if (_releasingFlag || _exitStatus == ExitCancel) {
LOG_ERROR(
"Node(%p) in the process of releasing/canceling, skip "
"closeStatusConnectNodeForConnectedPool.",
this);
_isConnected = false;
if (_audioFrame) {
free(_audioFrame);
_audioFrame = NULL;
}
_audioFrameSize = 0;
_maxFrameSize = 0;
_isFirstAudioFrame = true;
LOG_INFO(
"Node(%p) closeStatusConnectNodeForConnectedPool done, current node "
"status:%s exit "
"status:%s.",
this, getConnectNodeStatusString().c_str(),
getExitStatusString().c_str());
return;
}
}
LOG_DEBUG(
"Node(%p) closeStatusConnectNodeForConnectedPool begin, current node "
"status:%s exit "
"status:%s.",
this, getConnectNodeStatusString().c_str(),
getExitStatusString().c_str());
if (_nlsEncoder) {
_nlsEncoder->nlsEncoderSoftRestart();
}
_isConnected = false;
if (_url._enableSysGetAddr && _dnsEvent) {
event_del(_dnsEvent);
event_free(_dnsEvent);
_dnsEvent = NULL;
}
if (_readEvent) {
event_del(_readEvent);
event_free(_readEvent);
_readEvent = NULL;
// LOG_INFO("Node(%p) remove _readEvent", this);
}
if (_writeEvent) {
event_del(_writeEvent);
event_free(_writeEvent);
_writeEvent = NULL;
}
if (_connectEvent) {
event_del(_connectEvent);
event_free(_connectEvent);
_connectEvent = NULL;
}
if (_launchEvent) {
event_del(_launchEvent);
event_free(_launchEvent);
_launchEvent = NULL;
}
#ifdef ENABLE_PRECONNECTED_POOL
if (_startWithPoolEvent) {
event_del(_startWithPoolEvent);
event_free(_startWithPoolEvent);
_startWithPoolEvent = NULL;
}
#endif
#ifdef ENABLE_HIGH_EFFICIENCY
if (_connectTimerEvent != NULL) {
if (_connectTimerFlag) {
evtimer_del(_connectTimerEvent);
_connectTimerFlag = false;
}
event_free(_connectTimerEvent);
_connectTimerEvent = NULL;
}
#endif
if (_audioFrame) {
free(_audioFrame);
_audioFrame = NULL;
}
_audioFrameSize = 0;
_maxFrameSize = 0;
_isFirstAudioFrame = true;
_connectTimerFlag = false;
LOG_DEBUG(
"Node(%p) closeStatusConnectNodeForConnectedPool done, current node "
"status:%s exit "
"status:%s.",
this, getConnectNodeStatusString().c_str(),
getExitStatusString().c_str());
if (lock_ret) {
MUTEX_UNLOCK(_mtxCloseNode);
}
}