From 02ba913dc7bb5d711471b27f2ea23a897d0f2e28 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期五, 23 四月 2021 15:34:26 +0800 Subject: [PATCH] bind msgi to shm, change offset_ptr to abs offset. --- src/bh_api.cpp | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/bh_api.cpp b/src/bh_api.cpp index cdf2e96..f0ba26d 100644 --- a/src/bh_api.cpp +++ b/src/bh_api.cpp @@ -10,6 +10,7 @@ { TopicNode &ProcNode() { + static bool init_bind_msg_shm = MsgI::BindShm(BHomeShm()); static TopicNode node(BHomeShm()); return node; } @@ -157,19 +158,23 @@ return false; } -int BHAsyncRequest(const void *request, +int BHAsyncRequest(const void *remote, + const int remote_len, + const void *request, const int request_len, void **msg_id, int *msg_id_len) { + BHAddress dest; MsgRequestTopic req; - if (!req.ParseFromArray(request, request_len)) { + if (!dest.ParseFromArray(remote, remote_len) || + !req.ParseFromArray(request, request_len)) { SetLastError(eInvalidInput, "invalid input."); return false; } std::string str_msg_id; MsgRequestTopicReply out_msg; - if (ProcNode().ClientAsyncRequest(req, str_msg_id)) { + if (ProcNode().ClientAsyncRequest(dest, req, str_msg_id)) { if (!msg_id || !msg_id_len) { return true; } @@ -184,7 +189,9 @@ return false; } -int BHRequest(const void *request, +int BHRequest(const void *remote, + const int remote_len, + const void *request, const int request_len, void **proc_id, int *proc_id_len, @@ -192,14 +199,16 @@ int *reply_len, const int timeout_ms) { + BHAddress dest; MsgRequestTopic req; - if (!req.ParseFromArray(request, request_len)) { + if (!dest.ParseFromArray(remote, remote_len) || + !req.ParseFromArray(request, request_len)) { SetLastError(eInvalidInput, "invalid input."); return false; } std::string proc; MsgRequestTopicReply out_msg; - if (ProcNode().ClientSyncRequest(req, proc, out_msg, timeout_ms)) { + if (ProcNode().ClientSyncRequest(dest, req, proc, out_msg, timeout_ms)) { TmpPtr pproc(proc); if (pproc && PackOutput(out_msg, reply, reply_len)) { pproc.ReleaseTo(proc_id, proc_id_len); -- Gitblit v1.8.0