Parcourir la source

[3591] Print error to stderr after failing lock file creation.

Tomek Mrugalski il y a 10 ans
Parent
commit
493b7132b8
1 fichiers modifiés avec 13 ajouts et 3 suppressions
  1. 13 3
      src/lib/log/interprocess/interprocess_sync_file.cc

+ 13 - 3
src/lib/log/interprocess/interprocess_sync_file.cc

@@ -17,6 +17,8 @@
 #include <string>
 #include <cerrno>
 #include <cstring>
+#include <sstream>
+#include <iostream>
 
 #include <stdlib.h>
 #include <string.h>
@@ -60,9 +62,17 @@ InterprocessSyncFile::do_lock(int cmd, short l_type) {
         umask(mode);
 
         if (fd_ == -1) {
-            isc_throw(InterprocessSyncFileError,
-                      "Unable to use interprocess sync lockfile ("
-                      << std::strerror(errno) << "): " << lockfile_path);
+            std::stringstream tmp;
+
+            // We failed to create a lockfile. This means that the logging
+            // system is unusable. We need to report the issue using plain
+            // print to stderr.
+            tmp << "Unable to use interprocess sync lockfile ("
+                << std::strerror(errno) << "): " << lockfile_path;
+            std::cerr << tmp.str() << std::endl;
+
+            // And then throw exception as usual.
+            isc_throw(InterprocessSyncFileError, tmp.str());
         }
     }