in nlsCppSdk/transport/nodeManager.cpp [182:249]
int NlsNodeManager::removeRequestFromInfo(void* request, bool wait) {
MUTEX_LOCK(_mtxNodeManager);
if (request == NULL) {
LOG_ERROR("request is nullptr.");
MUTEX_UNLOCK(_mtxNodeManager);
return -(RequestEmpty);
}
int timeout = 0;
std::map<void*, NodeInfo>::iterator iter;
while (wait) {
iter = this->_infoByRequest.find(request);
if (iter != this->_infoByRequest.end()) {
NodeInfo& info = iter->second;
if (info.status != NodeStatusCreated && info.status < NodeStatusClosed) {
if (timeout >= this->_timeout_ms) {
LOG_WARN(
"request(%p) node(%p) status(%s) is invalid, wait timeout(%dms), "
"remove it by force.",
request, info.node,
this->getNodeStatusString(info.status).c_str(), timeout);
break;
}
LOG_DEBUG("request(%p) node(%p) status(%s) is waiting timeout(%dms)...",
request, info.node,
this->getNodeStatusString(info.status).c_str(), timeout);
MUTEX_UNLOCK(_mtxNodeManager);
#if defined(_MSC_VER)
Sleep(StepSleepMs);
#else
usleep(StepSleepMs * 1000);
#endif
timeout += StepSleepMs;
MUTEX_LOCK(_mtxNodeManager);
} else {
break;
}
} else {
break;
}
} // while
iter = this->_infoByRequest.find(request);
if (iter != this->_infoByRequest.end()) {
NodeInfo& info = iter->second;
void* node = info.node;
std::map<void*, void*>::iterator iter2;
iter2 = this->_requestListByNode.find(node);
if (iter2 != this->_requestListByNode.end()) {
this->_requestListByNode.erase(iter2);
}
LOG_INFO("request(%p) node(%p) status(%s) removed.", request, info.node,
this->getNodeStatusString(info.status).c_str());
_infoByRequest.erase(iter);
} else {
LOG_ERROR("request:%p isnot in NodeInfo", request);
MUTEX_UNLOCK(_mtxNodeManager);
return -(InvalidRequest);
}
MUTEX_UNLOCK(_mtxNodeManager);
return Success;
}