lichao
2021-04-30 3b93dc0dc34008cf25b2b12f6b026b3d9e4ed623
src/shm_msg_queue.cpp
@@ -84,19 +84,18 @@
   return Shmq::Find(shm, MsgQIdToName(remote_id));
}
bool ShmMsgQueue::TrySend(SharedMemory &shm, const MQId remote_id, const MsgI &msg, OnSend const &onsend)
bool ShmMsgQueue::TrySend(SharedMemory &shm, const MQId remote_id, MsgI msg)
{
   Queue *remote = Find(shm, remote_id);
   bool r = false;
   if (remote) {
      if (onsend) {
         return remote->TryWrite(msg, [&onsend](const MsgI &msg) { onsend(); msg.AddRef(); });
      } else {
         return remote->TryWrite(msg, [](const MsgI &msg) { msg.AddRef(); });
      msg.AddRef();
      r = remote->TryWrite(msg);
      if (!r) {
         msg.Release();
      }
   } else {
      // SetLestError(eNotFound);
      return false;
   }
   return r;
}
// Test shows that in the 2 cases: