From 1a6e46d71dcb3f5e3a25fa97d4e276a6621f0db2 Mon Sep 17 00:00:00 2001 From: BeyondWUXF <46481385+BeyondWUXF@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:24:05 +0800 Subject: [PATCH 1/2] Update ServerManager.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复往不存在的Admin reportNode --- NodeServer/ServerManager.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/NodeServer/ServerManager.cpp b/NodeServer/ServerManager.cpp index 8f81563..ea00bb0 100644 --- a/NodeServer/ServerManager.cpp +++ b/NodeServer/ServerManager.cpp @@ -252,17 +252,20 @@ void ServerManager::run() } - for(auto adminPrx : _adminPrxs) - { + auto itPrx = _adminPrxs.begin(); + while (itPrx != _adminPrxs.end()) + { try - { - adminPrx.second->reportNode(rn); + { + itPrx->second->reportNode(rn); + ++itPrx; } catch(exception &ex) { TLOG_ERROR("report admin, error:" << ex.what() << endl); + itPrx = _adminPrxs.erase(itPrx); } - } + } int64_t diff = timeout-(TNOWMS-now); @@ -897,4 +900,4 @@ int ServerManager::forceDockerLogin(vector &result) result = g_app.getDockerPullThread()->checkDockerRegistries(); return 0; -} \ No newline at end of file +} From 973d3bc0a7fbca734d47dc513314e6d80a366d59 Mon Sep 17 00:00:00 2001 From: BeyondWUXF <46481385+BeyondWUXF@users.noreply.github.com> Date: Mon, 13 Nov 2023 18:30:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?reportNode=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NodeServer/ServerManager.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/NodeServer/ServerManager.cpp b/NodeServer/ServerManager.cpp index ea00bb0..290bc70 100644 --- a/NodeServer/ServerManager.cpp +++ b/NodeServer/ServerManager.cpp @@ -236,8 +236,10 @@ void ServerManager::run() time_t now = TNOWMS; vector endPointList = Application::getCommunicator()->getEndpoint4All(_adminObj); - for(auto endPoint : endPointList) + set adminHosts; + for(auto &endPoint : endPointList) { + adminHosts.emplace(endPoint.getHost()); auto find = _adminPrxs.find(endPoint.getHost()); if(find == _adminPrxs.end()) { @@ -255,16 +257,22 @@ void ServerManager::run() auto itPrx = _adminPrxs.begin(); while (itPrx != _adminPrxs.end()) { + if(adminHosts.find(itPrx->first) == adminHosts.end()) + { + itPrx = _adminPrxs.erase(itPrx); + continue; + } + try { itPrx->second->reportNode(rn); - ++itPrx; } catch(exception &ex) { TLOG_ERROR("report admin, error:" << ex.what() << endl); - itPrx = _adminPrxs.erase(itPrx); } + + ++itPrx; } int64_t diff = timeout-(TNOWMS-now);