From 65ef4d68321e56906920be75831b5e968f7abd7b Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期二, 13 四月 2021 09:34:05 +0800 Subject: [PATCH] add heartbeat; refactor. --- src/shm_queue.cpp | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/shm_queue.cpp b/src/shm_queue.cpp index 652ed5b..8e4e56e 100644 --- a/src/shm_queue.cpp +++ b/src/shm_queue.cpp @@ -72,12 +72,22 @@ bool ShmMsgQueue::Send(SharedMemory &shm, const MQId &remote_id, const MsgI &msg, const int timeout_ms, OnSend const &onsend) { Queue *remote = Find(shm, MsgQIdToName(remote_id)); - return remote && remote->Write(msg, timeout_ms, [&onsend](const MsgI &msg) { onsend(); msg.AddRef(); }); + if (remote) { + return remote->Write(msg, timeout_ms, [&onsend](const MsgI &msg) { onsend(); msg.AddRef(); }); + } else { + // SetLestError(eNotFound); + return false; + } } bool ShmMsgQueue::Send(SharedMemory &shm, const MQId &remote_id, const MsgI &msg, const int timeout_ms) { Queue *remote = Find(shm, MsgQIdToName(remote_id)); - return remote && remote->Write(msg, timeout_ms, [](const MsgI &msg) { msg.AddRef(); }); + if (remote) { + return remote->Write(msg, timeout_ms, [](const MsgI &msg) { msg.AddRef(); }); + } else { + // SetLestError(eNotFound); + return false; + } } // Test shows that in the 2 cases: -- Gitblit v1.8.0