From 1c92e4cbc85f9501660444cb76ebb06770da9376 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期五, 21 五月 2021 15:36:11 +0800 Subject: [PATCH] reserve #xxx proc id for internal use. --- src/topic_node.cpp | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/src/topic_node.cpp b/src/topic_node.cpp index fce7ed6..124d329 100644 --- a/src/topic_node.cpp +++ b/src/topic_node.cpp @@ -143,8 +143,14 @@ for (auto &p : sockets_) { p->Stop(); } } -bool TopicNode::Register(ProcInfo &proc, MsgCommonReply &reply_body, const int timeout_ms) +bool TopicNode::UniRegister(const bool internal, ProcInfo &proc, MsgCommonReply &reply_body, const int timeout_ms) { + auto ValidUserProcId = [](const std::string &id) { return !id.empty() && id[0] != '#'; }; + if (!internal && !ValidUserProcId(proc.proc_id())) { + SetLastError(eInvalidInput, "invalid proc id :'" + proc.proc_id() + "'"); + return false; + } + { std::lock_guard<std::mutex> lk(mutex_); info_ = proc; -- Gitblit v1.8.0