in nlsCppSdk/transport/connectNode.cpp [2450:2576]
int ConnectNode::handlerFrame(NlsEvent *frameEvent) {
#ifdef ENABLE_NLS_DEBUG_2
uint64_t timewait_start, timewait_b, timewait_c, timewait_d, timewait_end;
timewait_start = utility::TextUtils::GetTimestampMs();
#endif
if (_workStatus == NodeInvalid) {
LOG_ERROR(
"Request(%p) Node(%p) current node status:%s is invalid, skip "
"callback.",
_request, this, getConnectNodeStatusString().c_str());
return -(InvaildNodeStatus);
} else {
if (_handler == NULL) {
LOG_ERROR("Request(%p) Node(%p) _handler is nullptr!", _request, this)
return -(NlsEventEmpty);
}
#ifdef ENABLE_REQUEST_RECORDING
#ifdef ENABLE_NLS_DEBUG_2
if (frameEvent->getMsgType() != NlsEvent::Binary) {
LOG_INFO("Request(%p) Node(%p) %s", _request, this,
frameEvent->getAllResponse());
}
#endif
updateNodeProcess("callback", frameEvent->getMsgType(), true,
frameEvent->getMsgType() == NlsEvent::Binary
? frameEvent->getBinaryData().size()
: 0);
#ifdef ENABLE_NLS_DEBUG_2
timewait_b = utility::TextUtils::GetTimestampMs();
#endif
#endif
// LOG_DEBUG(
// "Node:%p current node status:%s is valid, msg type:%s handle "
// "message... ",
// this, getConnectNodeStatusString().c_str(),
// frameEvent->getMsgTypeString().c_str());
// LOG_DEBUG("Node:%p current response:%s.", this,
// frameEvent->getAllResponse());
bool ignore_flag = false;
#ifdef ENABLE_CONTINUED
updateTwIndexOffset(frameEvent);
ignore_flag = ignoreCallbackWhenReconnecting(frameEvent->getMsgType(),
frameEvent->getStatusCode());
#endif
#ifdef ENABLE_NLS_DEBUG_2
timewait_c = utility::TextUtils::GetTimestampMs();
#endif
/* callback to user */
if (_enableOnMessage) {
sendFinishCondSignal(NlsEvent::Message);
if (!ignore_flag) {
handlerMessage(frameEvent->getAllResponse(), NlsEvent::Message);
}
} else {
#ifdef ENABLE_NLS_DEBUG_2
uint64_t timewait_c1, timewait_c2, timewait_c4;
timewait_c1 = utility::TextUtils::GetTimestampMs();
#endif
sendFinishCondSignal(frameEvent->getMsgType());
#ifdef ENABLE_NLS_DEBUG_2
timewait_c2 = utility::TextUtils::GetTimestampMs();
#endif
if (!ignore_flag) {
_handler->handlerFrame(*frameEvent);
}
#ifdef ENABLE_NLS_DEBUG_2
timewait_c4 = utility::TextUtils::GetTimestampMs();
if (timewait_c4 - timewait_c1 > 50) {
LOG_WARN(
"Request(%p) Node(%p) handlerFrame callback with excessive time "
"%llums, including sendFinishCondSignal:%llu handlerFrame:%llums.",
_request, this, timewait_c4 - timewait_c1,
timewait_c2 - timewait_c1, timewait_c4 - timewait_c2);
}
#endif
}
#ifdef ENABLE_NLS_DEBUG_2
timewait_d = utility::TextUtils::GetTimestampMs();
#endif
#ifdef ENABLE_REQUEST_RECORDING
updateNodeProcess("callback", NodeInvalid, false, 0);
#endif
if (frameEvent->getMsgType() == NlsEvent::Close) {
#ifdef ENABLE_CONTINUED
nodeReconnecting();
if (!ignore_flag) {
_reconnection.reconnected_count = 0;
LOG_DEBUG("Node(%p) reconnected_count reset.", this);
}
#endif
_retryConnectCount = 0;
} else if (frameEvent->getMsgType() == NlsEvent::TaskFailed) {
LOG_WARN("Request(%p) Node(%p) occur TaskFailed: %s", _request, this,
frameEvent->getAllResponse());
#ifdef ENABLE_PRECONNECTED_POOL
if (!ignore_flag && _request && NlsEventNetWork::_eventClient &&
NlsEventNetWork::_eventClient->getPreconnectedPool()) {
NlsType type = _request->getRequestParam()->_mode;
NlsEventNetWork::_eventClient->getPreconnectedPool()
->curRequestIsAbnormal(_request, type);
}
#endif
}
}
#ifdef ENABLE_NLS_DEBUG_2
timewait_end = utility::TextUtils::GetTimestampMs();
if (timewait_end - timewait_start > 50) {
LOG_WARN(
"Request(%p) Node(%p) handlerFrame done with excessive time "
"%llums, including updateNodeProcess:%llu ignore_flag:%llums "
"callback:%llums close:%llums.",
_request, this, timewait_end - timewait_start,
timewait_b - timewait_start, timewait_c - timewait_b,
timewait_d - timewait_c, timewait_end - timewait_d);
}
#endif
return Success;
}