From e391fc0858d94978bfb09aaab2b672ef7f2419b5 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 16 Sep 2013 11:08:13 +0200 Subject: [PATCH] Fix: Cluster log files were not properly removed when an instance has no peers. --- components/cluster/clustercomponent.cpp | 57 ++++++++++++------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/components/cluster/clustercomponent.cpp b/components/cluster/clustercomponent.cpp index ee1fe23bf..1a15f979a 100644 --- a/components/cluster/clustercomponent.cpp +++ b/components/cluster/clustercomponent.cpp @@ -519,40 +519,39 @@ void ClusterComponent::ClusterTimerHandler(void) Array::Ptr peers = GetPeers(); - if (!peers) - return; - - ObjectLock olock(peers); - BOOST_FOREACH(const String& peer, peers) { - Endpoint::Ptr endpoint = Endpoint::GetByName(peer); + if (peers) { + ObjectLock olock(peers); + BOOST_FOREACH(const String& peer, peers) { + Endpoint::Ptr endpoint = Endpoint::GetByName(peer); - if (!endpoint) { - Log(LogWarning, "cluster", "Attempted to reconnect to endpoint '" + peer + "': No configuration found."); - continue; - } + if (!endpoint) { + Log(LogWarning, "cluster", "Attempted to reconnect to endpoint '" + peer + "': No configuration found."); + continue; + } - if (endpoint->IsConnected()) - continue; + if (endpoint->IsConnected()) + continue; - String host, port; - host = endpoint->GetHost(); - port = endpoint->GetPort(); + String host, port; + host = endpoint->GetHost(); + port = endpoint->GetPort(); - if (host.IsEmpty() || port.IsEmpty()) { - Log(LogWarning, "cluster", "Can't reconnect " - "to endpoint '" + endpoint->GetName() + "': No " - "host/port information."); - continue; - } + if (host.IsEmpty() || port.IsEmpty()) { + Log(LogWarning, "cluster", "Can't reconnect " + "to endpoint '" + endpoint->GetName() + "': No " + "host/port information."); + continue; + } - try { - Log(LogInformation, "cluster", "Attempting to reconnect to cluster endpoint '" + endpoint->GetName() + "' via '" + host + ":" + port + "'."); - AddConnection(host, port); - } catch (std::exception& ex) { - std::ostringstream msgbuf; - msgbuf << "Exception occured while reconnecting to endpoint '" - << endpoint->GetName() << "': " << boost::diagnostic_information(ex); - Log(LogWarning, "cluster", msgbuf.str()); + try { + Log(LogInformation, "cluster", "Attempting to reconnect to cluster endpoint '" + endpoint->GetName() + "' via '" + host + ":" + port + "'."); + AddConnection(host, port); + } catch (std::exception& ex) { + std::ostringstream msgbuf; + msgbuf << "Exception occured while reconnecting to endpoint '" + << endpoint->GetName() << "': " << boost::diagnostic_information(ex); + Log(LogWarning, "cluster", msgbuf.str()); + } } } -- 2.40.0