]> granicus.if.org Git - icinga2/commitdiff
Throw exception if PerfdataWriter::RotateFile fails to rename from host_temp_path...
authorJason Young <jason.young@velaspan.com>
Mon, 14 Sep 2015 01:05:32 +0000 (21:05 -0400)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 11 May 2016 07:29:32 +0000 (09:29 +0200)
This can happen if the two paths are not on the same mount-point.

fixes #9236

Signed-off-by: Gunnar Beutner <gunnar.beutner@netways.de>
lib/perfdata/perfdatawriter.cpp

index 57cd3767333ed4a295c4273db969054ebc2c8fe1..7760045ec372ddbf20e46a000eac1879f0dd03e2 100644 (file)
@@ -124,7 +124,12 @@ void PerfdataWriter::RotateFile(std::ofstream& output, const String& temp_path,
                output.close();
 
                String finalFile = perfdata_path + "." + Convert::ToString((long)Utility::GetTime());
-               (void) rename(temp_path.CStr(), finalFile.CStr());
+               if (rename(temp_path.CStr(), finalFile.CStr()) < 0) {
+                       BOOST_THROW_EXCEPTION(posix_error()
+                           << boost::errinfo_api_function("rename")
+                           << boost::errinfo_errno(errno)
+                           << boost::errinfo_file_name(temp_path));
+               }
        }
 
        output.open(temp_path.CStr());