From a884637d0376d469ee307ebe1d117ae908a4c340 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期一, 13 十二月 2021 13:01:58 +0800 Subject: [PATCH] bug fixed for asyn rep-req timeout --- src/bn_api.cpp | 42 +++++++++++++++++++++++++++++++++--------- 1 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/bn_api.cpp b/src/bn_api.cpp index 292ef4b..93ead09 100644 --- a/src/bn_api.cpp +++ b/src/bn_api.cpp @@ -176,7 +176,19 @@ { if (!topic || topic_len <= 0) return false; - return simple_request(get_url(URLQueryTopic), topic, topic_len, reply, reply_len, timeout_ms); + auto url(get_url(URLQueryTopic)); + + if (remote && remote_len > 0){ + BHAddress addr; + if (addr.ParseFromArray(remote, remote_len)){ + if (!addr.ip().empty() && addr.port() > 0){ + // url = "tcp://" + addr.ip() + ":" + to_string(addr.port()); + printf("======>> BHQueryTopicAddress use remote address %s\n", url.c_str()); + } + } + } + + return simple_request(url, topic, topic_len, reply, reply_len, timeout_ms); } // 璇锋眰鍦ㄧ嚎杩涚▼ request @@ -190,9 +202,19 @@ { if (!query || query_len <= 0) return false; - auto ret = simple_request(get_url(URLQueryProcs), query, query_len, reply, reply_len, timeout_ms); - // printf("======>> BHQueryProcs *reply %p reply_len %d\n", *reply, *reply_len); - return ret; + auto url(get_url(URLQueryProcs)); + + if (remote && remote_len > 0){ + BHAddress addr; + if (addr.ParseFromArray(remote, remote_len)){ + if (!addr.ip().empty() && addr.port() > 0){ + // url = "tcp://" + addr.ip() + ":" + to_string(addr.port()); + printf("======>> BHQueryProcs use remote address %s\n", url.c_str()); + } + } + } + + return simple_request(url, query, query_len, reply, reply_len, timeout_ms); } // above communicate with center @@ -352,11 +374,13 @@ auto url("ipc:///tmp/" + procid); - BHAddress addr; - if (addr.ParseFromArray(remote, remote_len)){ - if (!addr.ip().empty() && addr.port() > 0){ - url = "tcp://" + addr.ip() + ":" + to_string(addr.port()); - printf("======>>use remote address %s\n", url.c_str()); + if (remote && remote_len > 0){ + BHAddress addr; + if (addr.ParseFromArray(remote, remote_len)){ + if (!addr.ip().empty() && addr.port() > 0){ + url = "tcp://" + addr.ip() + ":" + to_string(addr.port()); + printf("======>> BHRequest use remote address %s\n", url.c_str()); + } } } // 浣跨敤procid浣滀负ipc閫氫俊 -- Gitblit v1.8.0