[icinga-checkins] icinga.org: icinga2/master: Throw exception if PerfdataWriter:: RotateFile fails to rename from host_temp_path to host_perfdata_path ( and same for service)

git at icinga.org git at icinga.org
Tue May 17 11:44:10 CEST 2016


Module: icinga2
Branch: master
Commit: 88806b031b29bfa8585874b444630c90a6de37da
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=88806b031b29bfa8585874b444630c90a6de37da

Author: Jason Young <jason.young at velaspan.com>
Date:   Sun Sep 13 21:05:32 2015 -0400

Throw exception if PerfdataWriter::RotateFile fails to rename from host_temp_path to host_perfdata_path (and same for service)

This can happen if the two paths are not on the same mount-point.

fixes #9236

Signed-off-by: Gunnar Beutner <gunnar.beutner at netways.de>

---

 lib/perfdata/perfdatawriter.cpp |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/perfdata/perfdatawriter.cpp b/lib/perfdata/perfdatawriter.cpp
index 57cd376..7760045 100644
--- a/lib/perfdata/perfdatawriter.cpp
+++ b/lib/perfdata/perfdatawriter.cpp
@@ -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());



More information about the icinga-checkins mailing list