From ab3ee691b81c03348c5fd7dabd78128f77a7de85 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期四, 09 六月 2022 10:44:54 +0800 Subject: [PATCH] Merge branch 'master' of ssh://192.168.5.5:29418/valib/bus_nng into master --- src/interface_bus_api.cpp | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/interface_bus_api.cpp b/src/interface_bus_api.cpp index f2e7cfe..638f31a 100644 --- a/src/interface_bus_api.cpp +++ b/src/interface_bus_api.cpp @@ -108,8 +108,12 @@ } string msg(mtl2.SerializeAsString()); - - return simple_request(get_url(URLRegTopic), msg.data(), msg.size(), reply, reply_len, timeout_ms); + const auto& url = get_url(URLRegTopic); + if (url.empty()) { + set_last_error("bus_register_topics url empty"); + return false; + } + return simple_request(url, msg.data(), msg.size(), reply, reply_len, timeout_ms); } int bus_query_topic_address(void* handle, const void *remote, @@ -132,6 +136,10 @@ } auto url(get_url(URLQueryTopic)); + if (url.empty()) { + set_last_error("bus_query_topic_address url empty"); + return false; + } // if (remote && remote_len > 0){ // BHAddress addr; @@ -166,7 +174,10 @@ } auto url(get_url(URLQueryProcs)); - + if (url.empty()) { + set_last_error("bus_query_procs url empty"); + return false; + } // if (remote && remote_len > 0){ // BHAddress addr; // if (addr.ParseFromArray(remote, remote_len)){ @@ -340,11 +351,14 @@ 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()); + // printf("======>> BHRequest use remote address %s\n", url.c_str()); } } } - + if (url.empty()) { + set_last_error("bus_request url empty"); + return false; + } int rc = request2(url, request, request_len, reply, reply_len, timeout_ms); if (rc < 0) return false; copy_memory(proc_id, proc_id_len, procid.data(), procid.size()); -- Gitblit v1.8.0