log optimize

Signed-off-by: 李帅 <leo.lishuai@huawei.com>
This commit is contained in:
李帅 2024-09-19 11:02:56 +08:00
parent 79d51d55ac
commit e1389ed7e3
3 changed files with 16 additions and 2 deletions

View File

@ -180,8 +180,7 @@ void HdcChannelBase::WriteCallback(uv_write_t *req, int status)
--hChannel->ref;
HdcChannelBase *thisClass = (HdcChannelBase *)hChannel->clsChannel;
if (status < 0) {
WRITE_LOG(LOG_WARN, "WriteCallback TryCloseHandle channelId:%u isDead:%d ref:%d",
hChannel->channelId, hChannel->isDead, int32_t(hChannel->ref));
hChannel->writeFailedTimes++;
Base::TryCloseHandle((uv_handle_t *)req->handle);
if (!hChannel->isDead && !hChannel->ref) {
thisClass->FreeChannel(hChannel->channelId);
@ -475,6 +474,7 @@ void HdcChannelBase::FreeChannelOpeate(uv_timer_t *handle)
if (hChannel->ref > 0) {
return;
}
thisClass->DispMntnInfo(hChannel);
if (hChannel->hChildWorkTCP.loop) {
auto ctrl = HdcSessionBase::BuildCtrlString(SP_DEATCH_CHANNEL, hChannel->channelId, nullptr, 0);
thisClass->ChannelSendSessionCtrlMsg(ctrl, hChannel->targetSessionId);
@ -591,4 +591,14 @@ void HdcChannelBase::EchoToAllChannelsViaSessionId(uint32_t targetSessionId, con
}
}
}
void HdcChannelBase::DispMntnInfo(HChannel hChannel)
{
if (!hChannel) {
WRITE_LOG(LOG_WARN, "prt is null");
return;
}
WRITE_LOG(LOG_WARN, "channel info: id:%u isDead:%d ref:%u, writeFailedTimes:%u",
hChannel->channelId, hChannel->isDead, uint32_t(hChannel->ref), uint32_t(hChannel->writeFailedTimes));
}
}

View File

@ -78,6 +78,9 @@ private:
uv_rwlock_t lockMapChannel; // protect mapChannel
map<uint32_t, HChannel> mapChannel;
uv_thread_t threadChanneMain;
private:
void DispMntnInfo(HChannel hOutChannel);
};
} // namespace Hdc

View File

@ -338,6 +338,7 @@ struct HdcChannel {
bool fromClient = false;
bool connectLocalDevice = false;
bool isStableBuf = false;
std::atomic<uint32_t> writeFailedTimes;
};
using HChannel = struct HdcChannel *;