From 4b9dc13437cfd712a4e29473930e59dc6d400dc6 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Thu, 17 Apr 2025 06:53:12 +0000 Subject: [PATCH 01/34] update src/common/define_enum.h. Signed-off-by: liupeng298 --- src/common/define_enum.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/define_enum.h b/src/common/define_enum.h index a9739217..68a9b72c 100644 --- a/src/common/define_enum.h +++ b/src/common/define_enum.h @@ -68,7 +68,8 @@ enum OperateID { OP_INIT, OP_GET_ONLY, OP_VOTE_RESET, - OP_WAIT_FOR_ANY + OP_WAIT_FOR_ANY, + OP_PRINT }; enum RetErrCode { -- Gitee From 1c283fd8112a9ceb380f073e6454f72cc3805c11 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Thu, 17 Apr 2025 06:55:36 +0000 Subject: [PATCH 02/34] update src/common/define_plus.h. Signed-off-by: liupeng298 --- src/common/define_plus.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/common/define_plus.h b/src/common/define_plus.h index 8fef88ee..a045967b 100644 --- a/src/common/define_plus.h +++ b/src/common/define_plus.h @@ -253,6 +253,8 @@ struct HdcSession { bool isSoftReset; // for daemon, Used to record whether a reset command has been received HdcHeartbeat heartbeat; uv_timer_t heartbeatTimer; + bool isRunningOk; + std::string faultInfo; HdcSessionStat stat; std::string ToDebugString() @@ -268,6 +270,21 @@ struct HdcSession { return oss.str(); } +#ifdef HDC_HOST + std::string ToDisplayConnectionStr() + { + std::ostringstream oss; + oss << "HdcServer ["; + oss << " sessionId:" << sessionId; + oss << " connectKey:" << Hdc::MaskString(connectKey); + oss << " connType:" << unsigned(connType); + oss << " connect state:" << isRunningOk; + oss << " faultInfo:" << faultInfo; + oss << " ]"; + return oss.str(); + } +#endif + HdcSession() : serverOrDaemon(false), handshakeOK(false), isDead(false), voteReset(false), childLoopStatus(&childLoop, "ChildLoop") { @@ -302,6 +319,8 @@ struct HdcSession { #endif verifyType = AuthVerifyType::RSA_3072_SHA512; isSoftReset = false; + isRunningOk = true; + faultInfo = ""; } ~HdcSession() -- Gitee From 166837c5988cdfffe2be12acb4b9bec8fe51194c Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Thu, 17 Apr 2025 06:58:10 +0000 Subject: [PATCH 03/34] update src/common/session.cpp. Signed-off-by: liupeng298 --- src/common/session.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/common/session.cpp b/src/common/session.cpp index f4e6b4b4..9d7a02a8 100755 --- a/src/common/session.cpp +++ b/src/common/session.cpp @@ -512,6 +512,11 @@ HSession HdcSessionBase::MallocSession(bool serverOrDaemon, const ConnType connT return hSession; } +void HdcSessionBase::PrintAllSessionConnection() +{ + AdminSession(OP_PRINT, -1, nullptr); +} + void HdcSessionBase::FreeSessionByConnectType(HSession hSession) { WRITE_LOG(LOG_INFO, "FreeSessionByConnectType %s", hSession->ToDebugString().c_str()); @@ -578,6 +583,7 @@ void HdcSessionBase::FreeSessionFinally(uv_idle_t *handle) } // Notify Server or Daemon, just UI or display commandline thisClass->NotifyInstanceSessionFree(hSession, true); + thisClass->AdminSession(OP_PRINT, -1, nullptr); // all hsession uv handle has been clear thisClass->AdminSession(OP_REMOVE, hSession->sessionId, nullptr); WRITE_LOG(LOG_INFO, "!!!FreeSessionFinally sessionId:%u finish", hSession->sessionId); @@ -694,6 +700,15 @@ HSession HdcSessionBase::AdminSession(const uint8_t op, const uint32_t sessionId { HSession hRet = nullptr; switch (op) { + case OP_PRINT: + uv_rwlock_rdlock(&lockMapSession); + for (auto v : mapSession) { + HSession hSession = (HSession)v.second; + auto str = hSession->ToDisplayConnectionStr(); + WRITE_LOG(LOG_INFO, "%s", str.c_str()); + } + uv_rwlock_rdunlock(&lockMapSession); + break; case OP_ADD: uv_rwlock_wrlock(&lockMapSession); mapSession[sessionId] = hInput; -- Gitee From 262f7b8fe49e2813d7bab2154dec64b5ad8a80bd Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Thu, 17 Apr 2025 06:58:44 +0000 Subject: [PATCH 04/34] update src/common/session.h. Signed-off-by: liupeng298 --- src/common/session.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/session.h b/src/common/session.h index 3e0f898a..c9693b6b 100755 --- a/src/common/session.h +++ b/src/common/session.h @@ -96,6 +96,7 @@ public: virtual HSession MallocSession(bool serverOrDaemon, const ConnType connType, void *classModule, uint32_t sessionId = 0); virtual void FreeSession(const uint32_t sessionId); + void PrintAllSessionConnection(); void WorkerPendding(); int OnRead(HSession hSession, uint8_t *bufPtr, const int bufLen); int Send(const uint32_t sessionId, const uint32_t channelId, const uint16_t commandFlag, const uint8_t *data, -- Gitee From c23936b03045bf4ceb8045c7cf102ff45e07e927 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Thu, 17 Apr 2025 07:00:08 +0000 Subject: [PATCH 05/34] update src/common/tcp.cpp. Signed-off-by: liupeng298 --- src/common/tcp.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/tcp.cpp b/src/common/tcp.cpp index d6c7ca7f..7927f89e 100644 --- a/src/common/tcp.cpp +++ b/src/common/tcp.cpp @@ -79,6 +79,8 @@ void HdcTCPBase::ReadStream(uv_stream_t *tcp, ssize_t nread, const uv_buf_t *buf while (true) { if (nread == UV_ENOBUFS) { WRITE_LOG(LOG_WARN, "Session IOBuf max, sid:%u", hSession->sessionId); + hSession->isRunningOk = false; + hSession->faultInfo = "io buffer overflow"; break; } else if (nread < 0) { // I originally in the IO main thread, no need to send asynchronous messages, close the socket as soon as @@ -86,11 +88,15 @@ void HdcTCPBase::ReadStream(uv_stream_t *tcp, ssize_t nread, const uv_buf_t *buf constexpr int bufSize = 1024; char buffer[bufSize] = { 0 }; uv_strerror_r(static_cast(nread), buffer, bufSize); + hSession->isRunningOk = false; + hSession->faultInfo = buffer; WRITE_LOG(LOG_INFO, "HdcTCPBase::ReadStream < 0 %s sid:%u", buffer, hSession->sessionId); break; } if (hSessionBase->FetchIOBuf(hSession, hSession->ioBuf, nread) < 0) { WRITE_LOG(LOG_FATAL, "ReadStream FetchIOBuf error nread:%zd, sid:%u", nread, hSession->sessionId); + hSession->isRunningOk = false; + hSession->faultInfo = "package parse error"; break; } ret = true; -- Gitee From 3e2d0f4e40bdb8ec21254fdd86f103f7d95e5ddd Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Thu, 17 Apr 2025 07:01:03 +0000 Subject: [PATCH 06/34] update src/host/host_tcp.cpp. Signed-off-by: liupeng298 --- src/host/host_tcp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/host/host_tcp.cpp b/src/host/host_tcp.cpp index 2acd1378..81078eae 100644 --- a/src/host/host_tcp.cpp +++ b/src/host/host_tcp.cpp @@ -142,6 +142,7 @@ HSession HdcHostTCP::ConnectDaemon(const string &connectKey, bool isCheck) } hSession->isCheck = isCheck; hSession->connectKey = connectKey; + ptrConnect->PrintAllSessionConnection(); struct sockaddr_in dest; uv_ip4_addr(ip, port, &dest); uv_connect_t *conn = new(std::nothrow) uv_connect_t(); -- Gitee From d06a7e49d32fcfb58da3520457e1f626026d048f Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Thu, 17 Apr 2025 07:03:37 +0000 Subject: [PATCH 07/34] update src/host/host_usb.cpp. Signed-off-by: liupeng298 --- src/host/host_usb.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/host/host_usb.cpp b/src/host/host_usb.cpp index 8ebe533e..a78ce02d 100644 --- a/src/host/host_usb.cpp +++ b/src/host/host_usb.cpp @@ -176,6 +176,7 @@ bool HdcHostUSB::DetectMyNeed(libusb_device *device, string &sn) return false; } hSession->connectKey = hUSB->serialNumber; + hdcServer->PrintAllSessionConnection(); uv_timer_t *waitTimeDoCmd = new(std::nothrow) uv_timer_t; if (waitTimeDoCmd == nullptr) { WRITE_LOG(LOG_FATAL, "DetectMyNeed new waitTimeDoCmd failed"); @@ -594,12 +595,18 @@ int HdcHostUSB::SubmitUsbBio(HSession hSession, bool sendOrRecv, uint8_t *buf, i childRet = libusb_submit_transfer(ep->transfer); hUSB->lockDeviceHandle.unlock(); if (childRet < 0) { + hSession->isRunningOk = false; + hSession->faultInfo += libusb_error_name(ep->transfer->status); + hSession->faultInfo += " "; WRITE_LOG(LOG_FATAL, "SubmitUsbBio libusb_submit_transfer failed, sid:%u ret:%d", hSession->sessionId, childRet); break; } ep->cv.wait(lock, [ep]() { return ep->isComplete; }); if (ep->transfer->status != 0) { + hSession->isRunningOk = false; + hSession->faultInfo += libusb_error_name(ep->transfer->status); + hSession->faultInfo += " "; WRITE_LOG(LOG_FATAL, "SubmitUsbBio transfer failed, sid:%u status:%d", hSession->sessionId, ep->transfer->status); break; -- Gitee From ba5ebcf7838302a43eac40a2556a49a6623ca156 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Thu, 17 Apr 2025 07:04:52 +0000 Subject: [PATCH 08/34] update src/host/server.h. Signed-off-by: liupeng298 --- src/host/server.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/host/server.h b/src/host/server.h index d36ec9e5..6c5b6b31 100755 --- a/src/host/server.h +++ b/src/host/server.h @@ -38,6 +38,8 @@ public: HdcHostTCP *clsTCPClt; HdcHostUSB *clsUSBClt; + int totalConnectCount; + int totalFailCount; #ifdef HDC_SUPPORT_UART void CreatConnectUart(HSession hSession); static void UartPreConnect(uv_timer_t *handle); -- Gitee From 1f0b3b07f7ce0271080531efd12afdcdbeb59ab4 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Fri, 18 Apr 2025 06:50:55 +0000 Subject: [PATCH 09/34] update src/host/host_tcp.cpp. Signed-off-by: liupeng298 --- src/host/host_tcp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/host/host_tcp.cpp b/src/host/host_tcp.cpp index 81078eae..f85d7e11 100644 --- a/src/host/host_tcp.cpp +++ b/src/host/host_tcp.cpp @@ -103,6 +103,10 @@ void HdcHostTCP::Connect(uv_connect_t *connection, int status) auto ctrl = ptrConnect->BuildCtrlString(SP_START_SESSION, 0, nullptr, 0); if (status < 0) { WRITE_LOG(LOG_FATAL, "Connect status:%d", status); + hSession->isRunningOk = false; + char buffer[BUF_SIZE_DEFAULT] = { 0 }; + uv_strerror_r(status, buffer, BUF_SIZE_DEFAULT); + hSession->faultInfo += buffer; goto Finish; } if ((hSession->fdChildWorkTCP = Base::DuplicateUvSocket(&hSession->hWorkTCP)) < 0) { -- Gitee From 754e6b94b788bc225c9dda014fa835c7410ecf83 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Mon, 21 Apr 2025 11:09:51 +0000 Subject: [PATCH 10/34] update src/common/channel.cpp. Signed-off-by: liupeng298 --- src/common/channel.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/common/channel.cpp b/src/common/channel.cpp index 09b2854d..ed869ed5 100644 --- a/src/common/channel.cpp +++ b/src/common/channel.cpp @@ -124,6 +124,10 @@ void HdcChannelBase::ReadStream(uv_stream_t *tcp, ssize_t nread, const uv_buf_t if (nread == UV_ENOBUFS) { WRITE_LOG(LOG_FATAL, "ReadStream nobufs channelId:%u", channelId); + hChannel->isSuccess = false; + char buffer[BUF_SIZE_DEFAULT] = { 0 }; + uv_strerror_r(nread, buffer, BUF_SIZE_DEFAULT); + hChannel->faultInfo += buffer; return; } else if (nread == 0) { // maybe just after accept, second client req @@ -135,6 +139,10 @@ void HdcChannelBase::ReadStream(uv_stream_t *tcp, ssize_t nread, const uv_buf_t char buffer[bufSize] = { 0 }; uv_err_name_r(nread, buffer, bufSize); WRITE_LOG(LOG_DEBUG, "ReadStream channelId:%u failed:%s", channelId, buffer); + + hChannel->isSuccess = false; + hChannel->faultInfo += buffer; + needExit = true; goto Finish; } else { @@ -144,6 +152,8 @@ void HdcChannelBase::ReadStream(uv_stream_t *tcp, ssize_t nread, const uv_buf_t size = ntohl(*reinterpret_cast(hChannel->ioBuf + indexBuf)); // big endian if (size <= 0 || static_cast(size) > HDC_BUF_MAX_BYTES) { WRITE_LOG(LOG_FATAL, "ReadStream size:%d channelId:%u", size, channelId); + hChannel->isSuccess = false; + hChannel->faultInfo += "parse error: size field of the package header is too big"; needExit = true; break; } @@ -175,6 +185,8 @@ Finish: if (needExit) { thisClass->FreeChannel(hChannel->channelId); WRITE_LOG(LOG_DEBUG, "Read Stream needExit, FreeChannel finish channelId:%u", channelId); + } else { + hChannel->isSuccess = hChannel->faultInfo.size() == 0; } } @@ -455,6 +467,10 @@ void HdcChannelBase::FreeChannelFinally(uv_idle_t *handle) return; } thisClass->NotifyInstanceChannelFree(hChannel); + hChannel->endTime = Base::GetRuntimeMSec(); + if (hChannel->serverOrClient) { + thisClass->AdminChannel(OP_PRINT, -1, nullptr); + } thisClass->AdminChannel(OP_REMOVE, hChannel->channelId, nullptr); if (!hChannel->serverOrClient) { @@ -557,6 +573,15 @@ HChannel HdcChannelBase::AdminChannel(const uint8_t op, const uint32_t channelId { HChannel hRet = nullptr; switch (op) { + case OP_PRINT: + uv_rwlock_rdlock(&lockMapChannel); + for (auto v : mapChannel) { + HChannel hChannel = (HChannel)v.second; + auto str = hChannel->ToDisplayChannelStr(); + WRITE_LOG(LOG_INFO, "%s", str.c_str()); + } + uv_rwlock_rdunlock(&lockMapChannel); + break; case OP_ADD: uv_rwlock_wrlock(&lockMapChannel); mapChannel[channelId] = hInput; -- Gitee From e55ab555a89cb08a426428ad5ab747fddbd18668 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Mon, 21 Apr 2025 11:11:00 +0000 Subject: [PATCH 11/34] update src/common/define_plus.h. Signed-off-by: liupeng298 --- src/common/define_plus.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/common/define_plus.h b/src/common/define_plus.h index a045967b..ebdca954 100644 --- a/src/common/define_plus.h +++ b/src/common/define_plus.h @@ -377,6 +377,32 @@ struct HdcChannel { bool connectLocalDevice = false; bool isStableBuf = false; std::atomic writeFailedTimes; + uint64_t startTime = 0; + uint64_t endTime = 0; + bool isSuccess = false; + std::string faultInfo = ""; + uint16_t commandFlag = 0; + std::string commandParameters = ""; + bool isOnce = false; + +#ifdef HDC_HOST + std::string ToDisplayChannelStr() + { + std::ostringstream oss; + oss << "HdcServerForClient ["; + oss << " channelId:" << channelId; + oss << " connectKey:" << Hdc::MaskString(connectKey); + oss << " command flag:" << commandFlag; + oss << " command parameters:" << commandParameters; + oss << " command result:" << isSuccess; + oss << " command begin time:" << startTime; + oss << " command end time:" << endTime; + oss << " command take time:" << (endTime - startTime) << "ms"; + oss << " faultInfo:" << faultInfo; + oss << " ]"; + return oss.str(); + } +#endif }; using HChannel = struct HdcChannel *; -- Gitee From 96557536b05ca3c2469c61d74fb7ac68e29ad3b1 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Mon, 21 Apr 2025 11:15:19 +0000 Subject: [PATCH 12/34] update src/host/server_for_client.cpp. Signed-off-by: liupeng298 --- src/host/server_for_client.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/host/server_for_client.cpp b/src/host/server_for_client.cpp index 99ade4fc..b783c6a4 100755 --- a/src/host/server_for_client.cpp +++ b/src/host/server_for_client.cpp @@ -487,28 +487,33 @@ bool HdcServerForClient::DoCommandLocal(HChannel hChannel, void *formatCommandIn switch (formatCommand->cmdFlag) { case CMD_KERNEL_TARGET_DISCOVER: { OrderFindTargets(hChannel); + hChannel->isSuccess = true; ret = false; break; } case CMD_KERNEL_TARGET_LIST: { GetTargetList(hChannel, formatCommandInput); + hChannel->isSuccess = true; ret = false; break; } case CMD_SERVICE_START: { PrintLastError(hChannel); + hChannel->isSuccess = true; ret = false; break; } case CMD_CHECK_SERVER: { WRITE_LOG(LOG_DEBUG, "CMD_CHECK_SERVER command"); ReportServerVersion(hChannel); + hChannel->isSuccess = true; ret = false; break; } case CMD_WAIT_FOR: { WRITE_LOG(LOG_DEBUG, "CMD_WAIT_FOR command"); ret = !WaitForAny(hChannel); + hChannel->isSuccess = ret; break; } case CMD_KERNEL_TARGET_ANY: { @@ -516,6 +521,7 @@ bool HdcServerForClient::DoCommandLocal(HChannel hChannel, void *formatCommandIn WRITE_LOG(LOG_DEBUG, "%s CMD_KERNEL_TARGET_ANY %s", __FUNCTION__, formatCommand->parameters.c_str()); #endif ret = GetAnyTarget(hChannel); + hChannel->isSuccess = ret; break; } case CMD_KERNEL_TARGET_CONNECT: { @@ -523,6 +529,7 @@ bool HdcServerForClient::DoCommandLocal(HChannel hChannel, void *formatCommandIn WRITE_LOG(LOG_DEBUG, "%s CMD_KERNEL_TARGET_CONNECT %s", __FUNCTION__, formatCommand->parameters.c_str()); #endif ret = NewConnectTry(ptrServer, hChannel, formatCommand->parameters.c_str()); + hChannel->isSuccess = ret; break; } case CMD_CHECK_DEVICE: { @@ -530,10 +537,12 @@ bool HdcServerForClient::DoCommandLocal(HChannel hChannel, void *formatCommandIn hChannel->isCheck = true; hChannel->key = formatCommand->parameters.c_str(); ret = NewConnectTry(ptrServer, hChannel, formatCommand->parameters.c_str(), true); + hChannel->isSuccess = ret; break; } case CMD_KERNEL_TARGET_DISCONNECT: { CommandRemoveSession(hChannel, formatCommand->parameters.c_str()); + hChannel->isSuccess = true; break; } // task will be global task,Therefore, it can only be controlled in the global session. @@ -544,20 +553,25 @@ bool HdcServerForClient::DoCommandLocal(HChannel hChannel, void *formatCommandIn echo = EMPTY_ECHO; } EchoClient(hChannel, MSG_OK, const_cast(echo.c_str())); + hChannel->isSuccess = true; break; } case CMD_FORWARD_REMOVE: { RemoveForward(hChannel, formatCommand->parameters.c_str()); + hChannel->isSuccess = true; break; } case CMD_KERNEL_ENABLE_KEEPALIVE: { // just use for 'list targets' now hChannel->keepAlive = true; ret = true; + hChannel->isSuccess = true; break; } default: { EchoClient(hChannel, MSG_FAIL, "ExecuteCommand need connect-key? please confirm a device by help info"); + hChannel->isSuccess = false; + hChannel->faultInfo = "found no devices"; break; } } @@ -654,7 +668,6 @@ bool HdcServerForClient::DoCommandRemote(HChannel hChannel, void *formatCommandI switch (formatCommand->cmdFlag) { // Some simple commands only need to forward the instruction, no need to start Task case CMD_SHELL_INIT: - case CMD_SHELL_DATA: case CMD_UNITY_EXECUTE: case CMD_UNITY_EXECUTE_EX: case CMD_UNITY_REMOUNT: @@ -664,6 +677,9 @@ bool HdcServerForClient::DoCommandRemote(HChannel hChannel, void *formatCommandI case CMD_UNITY_ROOTRUN: case CMD_JDWP_TRACK: case CMD_JDWP_LIST: { + hChannel->commandFlag = formatCommand->cmdFlag; + hChannel->commandParameters = formatCommand->parameters; + case CMD_SHELL_DATA: if (!SendToDaemon(hChannel, formatCommand->cmdFlag, reinterpret_cast(const_cast(formatCommand->parameters.c_str())), sizeSend)) { break; @@ -684,6 +700,8 @@ bool HdcServerForClient::DoCommandRemote(HChannel hChannel, void *formatCommandI case CMD_FLASHD_FLASH_INIT: case CMD_FLASHD_ERASE: case CMD_FLASHD_FORMAT: { + hChannel->commandFlag = formatCommand->cmdFlag; + hChannel->commandParameters = formatCommand->parameters; TaskCommand(hChannel, formatCommandInput); ret = true; break; @@ -696,6 +714,7 @@ bool HdcServerForClient::DoCommandRemote(HChannel hChannel, void *formatCommandI } return ret; } + // Do not specify Target's operations no longer need to put it in the thread. bool HdcServerForClient::DoCommand(HChannel hChannel, void *formatCommandInput, HDaemonInfo &hdi) { @@ -705,6 +724,8 @@ bool HdcServerForClient::DoCommand(HChannel hChannel, void *formatCommandInput, formatCommand->cmdFlag == CMD_FORWARD_REMOVE || formatCommand->cmdFlag == CMD_SERVICE_START) { // Main thread command, direct Listen main thread + hChannel->commandFlag = formatCommand->cmdFlag; + hChannel->commandParameters = formatCommand->parameters; ret = DoCommandLocal(hChannel, formatCommandInput); } else { // CONNECT DAEMON's work thread command, non-primary thread if (!CommandMatchDaemonFeature(formatCommand->cmdFlag, hdi)) { -- Gitee From 24622c7bbfd964e47538ce1859ead388544ee747 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Mon, 21 Apr 2025 11:18:04 +0000 Subject: [PATCH 13/34] update src/common/define_plus.h. Signed-off-by: liupeng298 --- src/common/define_plus.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/define_plus.h b/src/common/define_plus.h index ebdca954..5de30902 100644 --- a/src/common/define_plus.h +++ b/src/common/define_plus.h @@ -377,7 +377,7 @@ struct HdcChannel { bool connectLocalDevice = false; bool isStableBuf = false; std::atomic writeFailedTimes; - uint64_t startTime = 0; + uint64_t startTime = 0; uint64_t endTime = 0; bool isSuccess = false; std::string faultInfo = ""; -- Gitee From 69cca5dc7617dbde79e2264e60da0b01ec0b6ad9 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Mon, 21 Apr 2025 11:37:40 +0000 Subject: [PATCH 14/34] update src/common/define_plus.h. Signed-off-by: liupeng298 --- src/common/define_plus.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/define_plus.h b/src/common/define_plus.h index 5de30902..d0ec0f58 100644 --- a/src/common/define_plus.h +++ b/src/common/define_plus.h @@ -385,7 +385,7 @@ struct HdcChannel { std::string commandParameters = ""; bool isOnce = false; -#ifdef HDC_HOST +#if defined(HDC_HOST) || defined(HDC_EMULATOR) std::string ToDisplayChannelStr() { std::ostringstream oss; -- Gitee From 1054c2a31144e22384efebf390cf610fa0c45766 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Mon, 21 Apr 2025 11:40:11 +0000 Subject: [PATCH 15/34] update src/common/define_plus.h. Signed-off-by: liupeng298 --- src/common/define_plus.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/define_plus.h b/src/common/define_plus.h index d0ec0f58..5de30902 100644 --- a/src/common/define_plus.h +++ b/src/common/define_plus.h @@ -385,7 +385,7 @@ struct HdcChannel { std::string commandParameters = ""; bool isOnce = false; -#if defined(HDC_HOST) || defined(HDC_EMULATOR) +#ifdef HDC_HOST std::string ToDisplayChannelStr() { std::ostringstream oss; -- Gitee From 38adb5c571a179b23cc5794d7de707271588516f Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Mon, 21 Apr 2025 11:41:14 +0000 Subject: [PATCH 16/34] update src/common/channel.cpp. Signed-off-by: liupeng298 --- src/common/channel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/channel.cpp b/src/common/channel.cpp index ed869ed5..5499effe 100644 --- a/src/common/channel.cpp +++ b/src/common/channel.cpp @@ -574,6 +574,7 @@ HChannel HdcChannelBase::AdminChannel(const uint8_t op, const uint32_t channelId HChannel hRet = nullptr; switch (op) { case OP_PRINT: +#ifdef HDC_HOST uv_rwlock_rdlock(&lockMapChannel); for (auto v : mapChannel) { HChannel hChannel = (HChannel)v.second; @@ -581,6 +582,7 @@ HChannel HdcChannelBase::AdminChannel(const uint8_t op, const uint32_t channelId WRITE_LOG(LOG_INFO, "%s", str.c_str()); } uv_rwlock_rdunlock(&lockMapChannel); +#endif break; case OP_ADD: uv_rwlock_wrlock(&lockMapChannel); -- Gitee From 6614c3f8fdd7bc5326852cb37abc28b8f9933f35 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Mon, 21 Apr 2025 11:49:18 +0000 Subject: [PATCH 17/34] update src/host/server_for_client.cpp. Signed-off-by: liupeng298 --- src/host/server_for_client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/host/server_for_client.cpp b/src/host/server_for_client.cpp index b783c6a4..8eb17c9f 100755 --- a/src/host/server_for_client.cpp +++ b/src/host/server_for_client.cpp @@ -676,10 +676,10 @@ bool HdcServerForClient::DoCommandRemote(HChannel hChannel, void *formatCommandI case CMD_UNITY_HILOG: case CMD_UNITY_ROOTRUN: case CMD_JDWP_TRACK: - case CMD_JDWP_LIST: { + case CMD_JDWP_LIST: hChannel->commandFlag = formatCommand->cmdFlag; hChannel->commandParameters = formatCommand->parameters; - case CMD_SHELL_DATA: + case CMD_SHELL_DATA: { if (!SendToDaemon(hChannel, formatCommand->cmdFlag, reinterpret_cast(const_cast(formatCommand->parameters.c_str())), sizeSend)) { break; -- Gitee From 56b40663234b37781cd3b91b34cedbef98f3ff14 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Tue, 22 Apr 2025 01:14:05 +0000 Subject: [PATCH 18/34] update src/common/session.cpp. Signed-off-by: liupeng298 --- src/common/session.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/session.cpp b/src/common/session.cpp index 9d7a02a8..59377f5c 100755 --- a/src/common/session.cpp +++ b/src/common/session.cpp @@ -701,6 +701,7 @@ HSession HdcSessionBase::AdminSession(const uint8_t op, const uint32_t sessionId HSession hRet = nullptr; switch (op) { case OP_PRINT: +#ifdef HDC_HOST uv_rwlock_rdlock(&lockMapSession); for (auto v : mapSession) { HSession hSession = (HSession)v.second; @@ -708,6 +709,7 @@ HSession HdcSessionBase::AdminSession(const uint8_t op, const uint32_t sessionId WRITE_LOG(LOG_INFO, "%s", str.c_str()); } uv_rwlock_rdunlock(&lockMapSession); +#endif break; case OP_ADD: uv_rwlock_wrlock(&lockMapSession); -- Gitee From 15bf2d9d7592930916e6f03f0ae96832410adf9d Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Tue, 22 Apr 2025 03:35:59 +0000 Subject: [PATCH 19/34] update src/common/session.cpp. Signed-off-by: liupeng298 --- src/common/session.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/session.cpp b/src/common/session.cpp index 59377f5c..3b817e2f 100755 --- a/src/common/session.cpp +++ b/src/common/session.cpp @@ -700,16 +700,22 @@ HSession HdcSessionBase::AdminSession(const uint8_t op, const uint32_t sessionId { HSession hRet = nullptr; switch (op) { - case OP_PRINT: + case OP_PRINT: { #ifdef HDC_HOST uv_rwlock_rdlock(&lockMapSession); + int count = 0; for (auto v : mapSession) { HSession hSession = (HSession)v.second; auto str = hSession->ToDisplayConnectionStr(); WRITE_LOG(LOG_INFO, "%s", str.c_str()); + if (hSession->isRunningOk) { + count++; + } } + WRITE_LOG(LOG_INFO, "alive session count:%d", count); uv_rwlock_rdunlock(&lockMapSession); #endif + } break; case OP_ADD: uv_rwlock_wrlock(&lockMapSession); -- Gitee From 2398f00457f75cb89d5f002aaec47a32fcd6d043 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Tue, 22 Apr 2025 03:37:29 +0000 Subject: [PATCH 20/34] update src/common/define_plus.h. Signed-off-by: liupeng298 --- src/common/define_plus.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/define_plus.h b/src/common/define_plus.h index 5de30902..490cd347 100644 --- a/src/common/define_plus.h +++ b/src/common/define_plus.h @@ -255,6 +255,7 @@ struct HdcSession { uv_timer_t heartbeatTimer; bool isRunningOk; std::string faultInfo; + uint64_t commandCount = 0; HdcSessionStat stat; std::string ToDebugString() @@ -280,6 +281,7 @@ struct HdcSession { oss << " connType:" << unsigned(connType); oss << " connect state:" << isRunningOk; oss << " faultInfo:" << faultInfo; + oss << " commandCount:" << commandCount; oss << " ]"; return oss.str(); } -- Gitee From 19cd0c09745aa3f5b5e62f50799426f61b9d1a34 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Tue, 22 Apr 2025 06:23:09 +0000 Subject: [PATCH 21/34] update src/host/server_for_client.cpp. Signed-off-by: liupeng298 --- src/host/server_for_client.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/host/server_for_client.cpp b/src/host/server_for_client.cpp index 8eb17c9f..a8a9d7c0 100755 --- a/src/host/server_for_client.cpp +++ b/src/host/server_for_client.cpp @@ -668,6 +668,7 @@ bool HdcServerForClient::DoCommandRemote(HChannel hChannel, void *formatCommandI switch (formatCommand->cmdFlag) { // Some simple commands only need to forward the instruction, no need to start Task case CMD_SHELL_INIT: + case CMD_SHELL_DATA: case CMD_UNITY_EXECUTE: case CMD_UNITY_EXECUTE_EX: case CMD_UNITY_REMOUNT: @@ -676,10 +677,7 @@ bool HdcServerForClient::DoCommandRemote(HChannel hChannel, void *formatCommandI case CMD_UNITY_HILOG: case CMD_UNITY_ROOTRUN: case CMD_JDWP_TRACK: - case CMD_JDWP_LIST: - hChannel->commandFlag = formatCommand->cmdFlag; - hChannel->commandParameters = formatCommand->parameters; - case CMD_SHELL_DATA: { + case CMD_JDWP_LIST: { if (!SendToDaemon(hChannel, formatCommand->cmdFlag, reinterpret_cast(const_cast(formatCommand->parameters.c_str())), sizeSend)) { break; @@ -700,8 +698,6 @@ bool HdcServerForClient::DoCommandRemote(HChannel hChannel, void *formatCommandI case CMD_FLASHD_FLASH_INIT: case CMD_FLASHD_ERASE: case CMD_FLASHD_FORMAT: { - hChannel->commandFlag = formatCommand->cmdFlag; - hChannel->commandParameters = formatCommand->parameters; TaskCommand(hChannel, formatCommandInput); ret = true; break; @@ -734,6 +730,10 @@ bool HdcServerForClient::DoCommand(HChannel hChannel, void *formatCommandInput, EchoClient(hChannel, MSG_FAIL, "[E002105] Unsupport command"); return false; } + if (formatCommand->cmdFlag != CMD_SHELL_DATA) { + hChannel->commandFlag = formatCommand->cmdFlag; + hChannel->commandParameters = formatCommand->parameters; + } ret = DoCommandRemote(hChannel, formatCommandInput); } return ret; -- Gitee From 67feaf20af8977b3f13ef86bcbff46a5f0eaee57 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Tue, 22 Apr 2025 06:45:59 +0000 Subject: [PATCH 22/34] update src/host/server_for_client.cpp. Signed-off-by: liupeng298 --- src/host/server_for_client.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/host/server_for_client.cpp b/src/host/server_for_client.cpp index a8a9d7c0..e4a69578 100755 --- a/src/host/server_for_client.cpp +++ b/src/host/server_for_client.cpp @@ -51,6 +51,7 @@ void HdcServerForClient::AcceptClient(uv_stream_t *server, int status) CALLSTAT_GUARD(thisClass->loopMainStatus, server->loop, "HdcServerForClient::AcceptClient"); HChannel hChannel = nullptr; uint32_t uid = thisClass->MallocChannel(&hChannel); + hChannel->startTime = Base::GetRuntimeMSec(); if (!hChannel) { WRITE_LOG(LOG_FATAL, "AcceptClient hChannel is nullptr"); return; -- Gitee From af1526a401c3c91c257406a7aa03627d03114075 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Tue, 22 Apr 2025 07:51:37 +0000 Subject: [PATCH 23/34] update src/host/server_for_client.cpp. Signed-off-by: liupeng298 --- src/host/server_for_client.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/host/server_for_client.cpp b/src/host/server_for_client.cpp index e4a69578..8039692d 100755 --- a/src/host/server_for_client.cpp +++ b/src/host/server_for_client.cpp @@ -749,16 +749,22 @@ HSession HdcServerForClient::FindAliveSessionFromDaemonMap(const HChannel hChann ptrServer->AdminDaemonMap(OP_QUERY, hChannel->connectKey, hdi); if (!hdi) { WRITE_LOG(LOG_WARN, "Not match target founded cid:%u", hChannel->channelId); + hChannel->isSuccess = false; + hChannel->faultInfo = "no match targets found"; EchoClient(hChannel, MSG_FAIL, "Not match target founded, check connect-key please"); return nullptr; } if (hdi->connStatus != STATUS_CONNECTED) { WRITE_LOG(LOG_WARN, "Device not found or connected cid:%u", hChannel->channelId); + hChannel->isSuccess = false; + hChannel->faultInfo = "device not found or connected"; EchoClient(hChannel, MSG_FAIL, "[E001005] Device not found or connected"); return nullptr; } if (hdi->hSession == nullptr || hdi->hSession->isDead) { WRITE_LOG(LOG_WARN, "Bind tartget session is null or dead cid:%u", hChannel->channelId); + hChannel->isSuccess = false; + hChannel->faultInfo = "bind tartget session is null or dead"; EchoClient(hChannel, MSG_FAIL, "Bind tartget session is dead"); return nullptr; } @@ -767,6 +773,8 @@ HSession HdcServerForClient::FindAliveSessionFromDaemonMap(const HChannel hChann hdi->hSession->sessionId, hChannel->channelId); const string errMsg = "[E000004]:The communication channel is being established.\r\n"\ "Please wait for several seconds and try again."; + hChannel->isSuccess = false; + hChannel->faultInfo = "handshake is not ready"; EchoClient(hChannel, MSG_FAIL, errMsg.c_str()); return nullptr; } -- Gitee From 5df484f6dccc7b0c3fbb49f7ff5d8f25fba88e4c Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Wed, 23 Apr 2025 01:19:12 +0000 Subject: [PATCH 24/34] update src/host/server_for_client.cpp. Signed-off-by: liupeng298 --- src/host/server_for_client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/host/server_for_client.cpp b/src/host/server_for_client.cpp index 8039692d..5950af12 100755 --- a/src/host/server_for_client.cpp +++ b/src/host/server_for_client.cpp @@ -774,7 +774,7 @@ HSession HdcServerForClient::FindAliveSessionFromDaemonMap(const HChannel hChann const string errMsg = "[E000004]:The communication channel is being established.\r\n"\ "Please wait for several seconds and try again."; hChannel->isSuccess = false; - hChannel->faultInfo = "handshake is not ready"; + hChannel->faultInfo = "handshake is not ready"; EchoClient(hChannel, MSG_FAIL, errMsg.c_str()); return nullptr; } -- Gitee From 5daf943073e18c1293f5caf402b0aad0ef0e570b Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Wed, 23 Apr 2025 01:43:58 +0000 Subject: [PATCH 25/34] update src/common/session.h. Signed-off-by: liupeng298 --- src/common/session.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/session.h b/src/common/session.h index c9693b6b..62727b23 100755 --- a/src/common/session.h +++ b/src/common/session.h @@ -150,6 +150,8 @@ protected: uint32_t dataSize; } __attribute__((packed)); void ClearSessions(); + void PrintSession(); + HSession VoteReset(const uint32_t sessionId); virtual void JdwpNewFileDescriptor(const uint8_t *buf, const int bytesIO) { } -- Gitee From fbd1b7c0c720d5c485102d775b30f2c7fe223bbc Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Wed, 23 Apr 2025 01:46:00 +0000 Subject: [PATCH 26/34] update src/common/session.cpp. Signed-off-by: liupeng298 --- src/common/session.cpp | 91 +++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/src/common/session.cpp b/src/common/session.cpp index 3b817e2f..ffaf601e 100755 --- a/src/common/session.cpp +++ b/src/common/session.cpp @@ -696,27 +696,58 @@ void HdcSessionBase::FreeSession(const uint32_t sessionId) } while (false); } -HSession HdcSessionBase::AdminSession(const uint8_t op, const uint32_t sessionId, HSession hInput) +void HdcSessionBase::PrintSession() { - HSession hRet = nullptr; - switch (op) { - case OP_PRINT: { #ifdef HDC_HOST - uv_rwlock_rdlock(&lockMapSession); - int count = 0; - for (auto v : mapSession) { - HSession hSession = (HSession)v.second; - auto str = hSession->ToDisplayConnectionStr(); - WRITE_LOG(LOG_INFO, "%s", str.c_str()); - if (hSession->isRunningOk) { - count++; - } + uv_rwlock_rdlock(&lockMapSession); + int count = 0; + for (auto v : mapSession) { + HSession hSession = (HSession)v.second; + auto str = hSession->ToDisplayConnectionStr(); + WRITE_LOG(LOG_INFO, "%s", str.c_str()); + if (hSession->isRunningOk) { + count++; } - WRITE_LOG(LOG_INFO, "alive session count:%d", count); - uv_rwlock_rdunlock(&lockMapSession); + } + WRITE_LOG(LOG_INFO, "alive session count:%d", count); + uv_rwlock_rdunlock(&lockMapSession); #endif +} + +HSession HdcSessionBase::VoteReset(const uint32_t sessionId) +{ + HSession hRet = nullptr; + bool needReset; + if (serverOrDaemon) { + uv_rwlock_wrlock(&lockMapSession); + hRet = mapSession[sessionId]; + hRet->voteReset = true; + needReset = true; + for (auto &kv : mapSession) { + if (sessionId == kv.first) { + continue; + } + WRITE_LOG(LOG_DEBUG, "session:%u vote reset, session %u is %s", + sessionId, kv.first, kv.second->voteReset ? "YES" : "NO"); + if (!kv.second->voteReset) { + needReset = false; + } } - break; + uv_rwlock_wrunlock(&lockMapSession); + } else { + needReset = true; + } + if (needReset) { + WRITE_LOG(LOG_FATAL, "!! session:%u vote reset, passed unanimously !!", sessionId); + abort(); + } + return hRet; +} + +HSession HdcSessionBase::AdminSession(const uint8_t op, const uint32_t sessionId, HSession hInput) +{ + HSession hRet = nullptr; + switch (op) { case OP_ADD: uv_rwlock_wrlock(&lockMapSession); mapSession[sessionId] = hInput; @@ -734,6 +765,9 @@ HSession HdcSessionBase::AdminSession(const uint8_t op, const uint32_t sessionId } uv_rwlock_rdunlock(&lockMapSession); break; + case OP_PRINT: + PrintSession(); + break; case OP_QUERY_REF: uv_rwlock_wrlock(&lockMapSession); if (mapSession.count(sessionId)) { @@ -753,30 +787,7 @@ HSession HdcSessionBase::AdminSession(const uint8_t op, const uint32_t sessionId if (mapSession.count(sessionId) == 0) { break; } - bool needReset; - if (serverOrDaemon) { - uv_rwlock_wrlock(&lockMapSession); - hRet = mapSession[sessionId]; - hRet->voteReset = true; - needReset = true; - for (auto &kv : mapSession) { - if (sessionId == kv.first) { - continue; - } - WRITE_LOG(LOG_DEBUG, "session:%u vote reset, session %u is %s", - sessionId, kv.first, kv.second->voteReset ? "YES" : "NO"); - if (!kv.second->voteReset) { - needReset = false; - } - } - uv_rwlock_wrunlock(&lockMapSession); - } else { - needReset = true; - } - if (needReset) { - WRITE_LOG(LOG_FATAL, "!! session:%u vote reset, passed unanimously !!", sessionId); - abort(); - } + hRet = VoteReset(sessionId); break; default: break; -- Gitee From b4299ffcc50578916a7c932d86a2d9b660739aa5 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Wed, 23 Apr 2025 06:59:56 +0000 Subject: [PATCH 27/34] update src/common/session.h. Signed-off-by: liupeng298 --- src/common/session.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/session.h b/src/common/session.h index 62727b23..bb246e1f 100755 --- a/src/common/session.h +++ b/src/common/session.h @@ -96,7 +96,7 @@ public: virtual HSession MallocSession(bool serverOrDaemon, const ConnType connType, void *classModule, uint32_t sessionId = 0); virtual void FreeSession(const uint32_t sessionId); - void PrintAllSessionConnection(); + void PrintAllSessionConnection(const uint32_t sessionId); void WorkerPendding(); int OnRead(HSession hSession, uint8_t *bufPtr, const int bufLen); int Send(const uint32_t sessionId, const uint32_t channelId, const uint16_t commandFlag, const uint8_t *data, -- Gitee From 08c7af5c86b7d9c394ad90f663be67c370a8a740 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Wed, 23 Apr 2025 07:02:16 +0000 Subject: [PATCH 28/34] update src/common/session.cpp. Signed-off-by: liupeng298 --- src/common/session.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/common/session.cpp b/src/common/session.cpp index ffaf601e..589c87bd 100755 --- a/src/common/session.cpp +++ b/src/common/session.cpp @@ -512,9 +512,9 @@ HSession HdcSessionBase::MallocSession(bool serverOrDaemon, const ConnType connT return hSession; } -void HdcSessionBase::PrintAllSessionConnection() +void HdcSessionBase::PrintAllSessionConnection(const uint32_t sessionId) { - AdminSession(OP_PRINT, -1, nullptr); + AdminSession(OP_PRINT, sessionId, nullptr); } void HdcSessionBase::FreeSessionByConnectType(HSession hSession) @@ -583,7 +583,7 @@ void HdcSessionBase::FreeSessionFinally(uv_idle_t *handle) } // Notify Server or Daemon, just UI or display commandline thisClass->NotifyInstanceSessionFree(hSession, true); - thisClass->AdminSession(OP_PRINT, -1, nullptr); + thisClass->AdminSession(OP_PRINT, hSession->sessionId, nullptr); // all hsession uv handle has been clear thisClass->AdminSession(OP_REMOVE, hSession->sessionId, nullptr); WRITE_LOG(LOG_INFO, "!!!FreeSessionFinally sessionId:%u finish", hSession->sessionId); @@ -696,7 +696,7 @@ void HdcSessionBase::FreeSession(const uint32_t sessionId) } while (false); } -void HdcSessionBase::PrintSession() +void HdcSessionBase::PrintSession(const uint32_t sessionId) { #ifdef HDC_HOST uv_rwlock_rdlock(&lockMapSession); @@ -704,7 +704,12 @@ void HdcSessionBase::PrintSession() for (auto v : mapSession) { HSession hSession = (HSession)v.second; auto str = hSession->ToDisplayConnectionStr(); - WRITE_LOG(LOG_INFO, "%s", str.c_str()); + if (hSession->sessionId == sessionId) { + str = str + " (Current)"; + WRITE_LOG(LOG_INFO, "%s", str.c_str()); + } else { + WRITE_LOG(LOG_DEBUG, "%s", str.c_str()); + } if (hSession->isRunningOk) { count++; } @@ -766,7 +771,7 @@ HSession HdcSessionBase::AdminSession(const uint8_t op, const uint32_t sessionId uv_rwlock_rdunlock(&lockMapSession); break; case OP_PRINT: - PrintSession(); + PrintSession(sessionId); break; case OP_QUERY_REF: uv_rwlock_wrlock(&lockMapSession); -- Gitee From 63ddcea3a57281b2fc674b90a68fd023400af1fb Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Wed, 23 Apr 2025 07:03:16 +0000 Subject: [PATCH 29/34] update src/host/host_tcp.cpp. Signed-off-by: liupeng298 --- src/host/host_tcp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/host/host_tcp.cpp b/src/host/host_tcp.cpp index f85d7e11..8deb0e32 100644 --- a/src/host/host_tcp.cpp +++ b/src/host/host_tcp.cpp @@ -146,7 +146,7 @@ HSession HdcHostTCP::ConnectDaemon(const string &connectKey, bool isCheck) } hSession->isCheck = isCheck; hSession->connectKey = connectKey; - ptrConnect->PrintAllSessionConnection(); + ptrConnect->PrintAllSessionConnection(hSession->sessionId); struct sockaddr_in dest; uv_ip4_addr(ip, port, &dest); uv_connect_t *conn = new(std::nothrow) uv_connect_t(); -- Gitee From d71814ef3dcc6d55cd0b8222f75e1a6ccffe1a71 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Wed, 23 Apr 2025 07:04:06 +0000 Subject: [PATCH 30/34] update src/host/host_usb.cpp. Signed-off-by: liupeng298 --- src/host/host_usb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/host/host_usb.cpp b/src/host/host_usb.cpp index a78ce02d..ed7ebd67 100644 --- a/src/host/host_usb.cpp +++ b/src/host/host_usb.cpp @@ -176,7 +176,7 @@ bool HdcHostUSB::DetectMyNeed(libusb_device *device, string &sn) return false; } hSession->connectKey = hUSB->serialNumber; - hdcServer->PrintAllSessionConnection(); + hdcServer->PrintAllSessionConnection(hSession->sessionId); uv_timer_t *waitTimeDoCmd = new(std::nothrow) uv_timer_t; if (waitTimeDoCmd == nullptr) { WRITE_LOG(LOG_FATAL, "DetectMyNeed new waitTimeDoCmd failed"); -- Gitee From dee1c9e1a87841ca81bc80c2660116d9c0cba23d Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Wed, 23 Apr 2025 07:06:20 +0000 Subject: [PATCH 31/34] update src/common/define_plus.h. Signed-off-by: liupeng298 --- src/common/define_plus.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/common/define_plus.h b/src/common/define_plus.h index 490cd347..c0c0936b 100644 --- a/src/common/define_plus.h +++ b/src/common/define_plus.h @@ -397,8 +397,6 @@ struct HdcChannel { oss << " command flag:" << commandFlag; oss << " command parameters:" << commandParameters; oss << " command result:" << isSuccess; - oss << " command begin time:" << startTime; - oss << " command end time:" << endTime; oss << " command take time:" << (endTime - startTime) << "ms"; oss << " faultInfo:" << faultInfo; oss << " ]"; -- Gitee From 8ceddda61cf5915114276c9b8ea8a165292f917a Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Wed, 23 Apr 2025 07:23:46 +0000 Subject: [PATCH 32/34] update src/host/server.h. Signed-off-by: liupeng298 --- src/host/server.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/host/server.h b/src/host/server.h index 6c5b6b31..d36ec9e5 100755 --- a/src/host/server.h +++ b/src/host/server.h @@ -38,8 +38,6 @@ public: HdcHostTCP *clsTCPClt; HdcHostUSB *clsUSBClt; - int totalConnectCount; - int totalFailCount; #ifdef HDC_SUPPORT_UART void CreatConnectUart(HSession hSession); static void UartPreConnect(uv_timer_t *handle); -- Gitee From 377273a868edf4381f377ba714a1b8b2d9dc7480 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Thu, 24 Apr 2025 02:24:19 +0000 Subject: [PATCH 33/34] update src/common/session.h. Signed-off-by: liupeng298 --- src/common/session.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/session.h b/src/common/session.h index bb246e1f..aeadbaf9 100755 --- a/src/common/session.h +++ b/src/common/session.h @@ -150,7 +150,7 @@ protected: uint32_t dataSize; } __attribute__((packed)); void ClearSessions(); - void PrintSession(); + void PrintSession(const uint32_t sessionId); HSession VoteReset(const uint32_t sessionId); virtual void JdwpNewFileDescriptor(const uint8_t *buf, const int bytesIO) { -- Gitee From 8f3ea01bf0431a405d4566e74c0914e8a3f6ffe8 Mon Sep 17 00:00:00 2001 From: liupeng298 Date: Thu, 24 Apr 2025 02:25:49 +0000 Subject: [PATCH 34/34] update src/common/session.cpp. Signed-off-by: liupeng298 --- src/common/session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/session.cpp b/src/common/session.cpp index 589c87bd..23c8431f 100755 --- a/src/common/session.cpp +++ b/src/common/session.cpp @@ -733,7 +733,7 @@ HSession HdcSessionBase::VoteReset(const uint32_t sessionId) continue; } WRITE_LOG(LOG_DEBUG, "session:%u vote reset, session %u is %s", - sessionId, kv.first, kv.second->voteReset ? "YES" : "NO"); + sessionId, kv.first, kv.second->voteReset ? "YES" : "NO"); if (!kv.second->voteReset) { needReset = false; } -- Gitee