]> granicus.if.org Git - icinga2/commitdiff
cluster: Re-open logfile after log replay.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 16 Sep 2013 08:06:09 +0000 (10:06 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 16 Sep 2013 08:06:09 +0000 (10:06 +0200)
components/cluster/clustercomponent.cpp

index 031fade310c3a4e468a62b06fb253b98445ce45e..e34833d595d04d5b32af32a5a7cd224bce3f6dd8 100644 (file)
@@ -336,10 +336,6 @@ void ClusterComponent::ReplayLog(const Endpoint::Ptr& endpoint, const Stream::Pt
                CloseLogFile();
                RotateLogFile();
 
-               std::vector<int> files;
-               Utility::Glob(GetClusterDir() + "log/*", boost::bind(&ClusterComponent::LogGlobHandler, boost::ref(files), _1));
-               std::sort(files.begin(), files.end());
-
                if (count == -1 || count > 50000) {
                        OpenLogFile();
                        olock.Unlock();
@@ -349,6 +345,10 @@ void ClusterComponent::ReplayLog(const Endpoint::Ptr& endpoint, const Stream::Pt
 
                count = 0;
 
+               std::vector<int> files;
+               Utility::Glob(GetClusterDir() + "log/*", boost::bind(&ClusterComponent::LogGlobHandler, boost::ref(files), _1));
+               std::sort(files.begin(), files.end());
+
                BOOST_FOREACH(int ts, files) {
                        String path = GetClusterDir() + "log/" + Convert::ToString(ts);
 
@@ -391,9 +391,13 @@ void ClusterComponent::ReplayLog(const Endpoint::Ptr& endpoint, const Stream::Pt
                Log(LogInformation, "cluster", "Replayed " + Convert::ToString(count) + " messages.");
 
                if (last_sync) {
-                       ObjectLock olock2(endpoint);
+                       {
+                               ObjectLock olock2(endpoint);
+                               endpoint->SetSyncing(false);
+                       }
+
+                       OpenLogFile();
 
-                       endpoint->SetSyncing(false);
                        break;
                }
        }