From c765abc0380460a241f96ec931db203700c81b70 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期四, 20 一月 2022 17:03:40 +0800 Subject: [PATCH] performance --- src/bn_api.cpp | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/bn_api.cpp b/src/bn_api.cpp index 07773df..2ea2429 100644 --- a/src/bn_api.cpp +++ b/src/bn_api.cpp @@ -42,7 +42,7 @@ unsigned short port = *(unsigned short*)(out); copy_memory(reply, reply_len, (char*)out + port_size, out_len - port_size); BHFree(out, out_len); - printf("======>> recv port %d\n", port); + // printf("======>> recv port %d\n", port); ///////////////////////////////////////////////////////////////////////// const auto& url_pub_proxy = get_url(URLPubProxy); @@ -198,9 +198,7 @@ return true; } -// 璁㈤槄 -int BHSubscribeTopics(const void *topics, const int topics_len, void **reply, int *reply_len, const int timeout_ms) -{ +static int sub(const string& url, const void *topics, const int topics_len, void **reply, int *reply_len, const int timeout_ms){ if (!topics || topics_len <= 0) return false; bhome_msg::MsgTopicList mtl; @@ -218,17 +216,22 @@ // printf("BHSubscribeTopics %s\n", t.c_str()); subscribe_topic(t); } - return true; - auto ret = simple_request(get_url(URLSubLocal), topics, topics_len, reply, reply_len, timeout_ms); + + auto ret = simple_request(url, topics, topics_len, reply, reply_len, timeout_ms); if (!ret){ printf("BHSubscribeTopics simple_request failed\n"); } return ret; } +// 璁㈤槄 +int BHSubscribeTopics(const void *topics, const int topics_len, void **reply, int *reply_len, const int timeout_ms) +{ + return sub(get_url(URLSubLocal), topics, topics_len, reply, reply_len, timeout_ms); +} // 璁㈤槄缃戠粶,涓嶅疄鐜� int BHSubscribeNetTopics(const void *topics, const int topics_len, void **reply, int *reply_len, const int timeout_ms) { - return BHSubscribeTopics(topics, topics_len, reply, reply_len, timeout_ms); + return sub(get_url(URLSubNet), topics, topics_len, reply, reply_len, timeout_ms); } // 璇诲彇璁㈤槄娑堟伅,proc_id鏆傛椂娌$敤锛岃繑鍥瀎ake msg @@ -332,7 +335,7 @@ 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()); } } } -- Gitblit v1.8.0