]> granicus.if.org Git - icinga2/commitdiff
Fix: Cluster log files were not properly removed when an instance has no peers.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 16 Sep 2013 09:08:13 +0000 (11:08 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 16 Sep 2013 09:08:13 +0000 (11:08 +0200)
components/cluster/clustercomponent.cpp

index ee1fe23bfc3ecb88b30e3ceb2fdc435a45bb7bc4..1a15f979ad01f67ee6af61d24b13a9a8fdf65c09 100644 (file)
@@ -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());
+                       }
                }
        }