Add maintenance logs related to forward

Signed-off-by: wenlong_12 <wenlong12@huawei.com>
Change-Id: If329eeb8d5589b5efd58b95808c77e64359785f8
This commit is contained in:
wenlong_12 2024-08-30 11:38:12 +08:00
parent 12e6afd992
commit baa8cbe39e

View File

@ -171,7 +171,6 @@ void HdcForwardBase::FreeJDWP(HCtxForward ctx)
void HdcForwardBase::FreeContext(HCtxForward ctxIn, const uint32_t id, bool bNotifyRemote)
{
WRITE_LOG(LOG_DEBUG, "FreeContext id:%u, bNotifyRemote:%d", id, bNotifyRemote);
std::lock_guard<std::mutex> lock(ctxFreeMutex);
HCtxForward ctx = nullptr;
if (!ctxIn) {
@ -182,6 +181,8 @@ void HdcForwardBase::FreeContext(HCtxForward ctxIn, const uint32_t id, bool bNot
} else {
ctx = ctxIn;
}
WRITE_LOG(LOG_DEBUG, "FreeContext id:%u, bNotifyRemote:%d, finish:%d",
ctx->id, bNotifyRemote, ctx->finish);
if (ctx->finish) {
return;
}
@ -736,15 +737,16 @@ int HdcForwardBase::SendForwardBuf(HCtxForward ctx, uint8_t *bufPtr, const int s
{
int nRet = 0;
if (size > static_cast<int>(HDC_BUF_MAX_BYTES - 1)) {
WRITE_LOG(LOG_WARN, "SendForwardBuf size:%d > HDC_BUF_MAX_BYTES", size);
WRITE_LOG(LOG_WARN, "SendForwardBuf size:%d > HDC_BUF_MAX_BYTES, ctxId:%u", size, ctx->id);
return -1;
}
if (size <= 0) {
WRITE_LOG(LOG_WARN, "SendForwardBuf failed size:%d", size);
WRITE_LOG(LOG_WARN, "SendForwardBuf failed size:%d, ctxId:%u", size, ctx->id);
return -1;
}
auto pDynBuf = new(std::nothrow) uint8_t[size];
if (!pDynBuf) {
WRITE_LOG(LOG_WARN, "SendForwardBuf new DynBuf failed size:%d, ctxId:%u", size, ctx->id);
return -1;
}
(void)memcpy_s(pDynBuf, size, bufPtr, size);
@ -753,6 +755,7 @@ int HdcForwardBase::SendForwardBuf(HCtxForward ctx, uint8_t *bufPtr, const int s
} else {
auto ctxIO = new ContextForwardIO();
if (!ctxIO) {
WRITE_LOG(LOG_WARN, "SendForwardBuf new ContextForwardIO failed, ctxId:%u", ctx->id);
delete[] pDynBuf;
return -1;
}
@ -766,6 +769,10 @@ int HdcForwardBase::SendForwardBuf(HCtxForward ctx, uint8_t *bufPtr, const int s
nRet = Base::SendToStreamEx((uv_stream_t *)&ctx->pipe, pDynBuf, size, nullptr,
(void *)SendCallbackForwardBuf, (void *)ctxIO);
}
if (nRet < 0) {
WRITE_LOG(LOG_WARN, "SendForwardBuf SendToStreamEx ret:%d, size:%d ctxId:%u type:%d",
nRet, size, ctx->id, ctx->type);
}
}
return nRet;
}
@ -820,6 +827,7 @@ bool HdcForwardBase::ForwardCommandDispatch(const uint16_t command, uint8_t *pay
break;
}
if (SendForwardBuf(ctx, pContent, sizeContent) < 0) {
WRITE_LOG(LOG_WARN, "ForwardCommandDispatch SendForwardBuf rc < 0, ctxid:%u", ctx->id);
FreeContext(ctx, 0, true);
}
break;