From eeb6dc82c1c8ab715cb68d66518560e6542d2af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zen=E7=9F=A5=E4=BB=81?= Date: Tue, 15 Nov 2022 19:16:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=A4=B1=E8=B4=A5=E5=9C=BA=E6=99=AF=E4=B8=8B?= =?UTF-8?q?=EF=BC=8C=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E=E4=B8=8D=E5=8F=8A?= =?UTF-8?q?=E6=97=B6=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zen知仁 Change-Id: I4ab67d456e925d44ace0684b3d09ad56497df542 --- .../messenger_device_session_manager.c | 18 ++++++++++++++++++ .../messenger_device_status_manager.cpp | 11 ++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/baselib/msglib/src/standard/messenger_device_session_manager.c b/baselib/msglib/src/standard/messenger_device_session_manager.c index c2335f8..3f1d2a4 100644 --- a/baselib/msglib/src/standard/messenger_device_session_manager.c +++ b/baselib/msglib/src/standard/messenger_device_session_manager.c @@ -107,6 +107,22 @@ static void ProcessSessionMessageReceived(const uint8_t *data, uint32_t len) FREE(queueData); } +static void ProcessMessageSendFailed(const DeviceIdentify *devId, uint64_t transNo, uint32_t result) +{ + if (devId == NULL) { + return; + } + + DeviceSessionManager *instance = GetDeviceSessionManagerInstance(); + + MessageSendResultNotifier notifier = instance->sendResultNotifier; + if (notifier == NULL) { + SECURITY_LOG_ERROR("sendResultNotifier is null"); + return; + } + notifier(devId, transNo, result); +} + static void OnSessionMessageReceived(const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen) { DeviceSessionManager *instance = GetDeviceSessionManagerInstance(); @@ -216,6 +232,7 @@ static int MessengerOnSessionOpened(int sessionId, int result) int sent = SendBytes(sessionId, msgData->msgData, msgData->msgLen); if (sent != 0) { SECURITY_LOG_ERROR("SendBytes error code = %{public}d", ret); + ProcessMessageSendFailed(&msgData->destIdentity, msgData->transNo, sent); } FREE(msgData); } @@ -453,6 +470,7 @@ void MessengerSendMsgTo(uint64_t transNo, const DeviceIdentify *devId, const uin int ret = SendBytes(sessionId, msg, msgLen); if (ret != 0) { SECURITY_LOG_ERROR("SendBytes error code = %{public}d", ret); + ProcessMessageSendFailed(devId, transNo, ret); } return; } diff --git a/baselib/msglib/src/standard/messenger_device_status_manager.cpp b/baselib/msglib/src/standard/messenger_device_status_manager.cpp index 955f9ca..6d3690e 100644 --- a/baselib/msglib/src/standard/messenger_device_status_manager.cpp +++ b/baselib/msglib/src/standard/messenger_device_status_manager.cpp @@ -79,6 +79,11 @@ public: EVENT_NODE_STATE_OFFLINE = 0, EVENT_NODE_STATE_ONLINE = 1, }; + struct QueueStatusData { + DeviceIdentify srcIdentity {0, {0}}; + uint32_t status {0}; + uint32_t devType {0}; + }; DslmDeviceState() = default; ~DslmDeviceState() override = default; @@ -126,11 +131,7 @@ public: SECURITY_LOG_ERROR("ProcessDeviceStatusReceiver, invalid queue"); return; } - struct QueueStatusData { - DeviceIdentify srcIdentity {0, {0}}; - uint32_t status {0}; - uint32_t devType {0}; - }; + QueueStatusData *data = new (std::nothrow) QueueStatusData; if (data == nullptr) { SECURITY_LOG_ERROR("ProcessDeviceStatusReceiver, malloc result null"); -- Gitee