From 3788226ee9332945e90066b58f2b85026c2a0460 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期二, 18 五月 2021 10:56:32 +0800 Subject: [PATCH] change node init, no shm lock any more. --- src/socket.cpp | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/socket.cpp b/src/socket.cpp index 55b43f9..c450e65 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -162,7 +162,7 @@ { size_t size = content.size(); auto OnResult = [content = std::move(content), msg_id, remote, cb = std::move(cb), this](MsgI &msg) mutable { - if (!msg.Fill(content)) { return; } + if (!msg.Fill(content)) { return false; } try { if (!cb) { @@ -175,12 +175,23 @@ }; Send(remote, msg, onExpireRemoveCB); } + return true; } catch (...) { SetLastError(eError, "Send internal error."); + return false; } }; - +#if 0 + // self alloc + MsgI msg; + if (msg.Make(size)) { + DEFER1(msg.Release()); + return OnResult(msg); + } +#else + // center alloc return RequestAlloc(size, OnResult); +#endif } bool ShmSocket::RequestAlloc(const int64_t size, std::function<void(MsgI &msg)> const &onResult) -- Gitblit v1.8.0