Browse Source

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

Tomek Mrugalski 10 years ago
parent
commit
493b7132b8
1 changed files with 13 additions and 3 deletions
  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 <string>
 #include <cerrno>
 #include <cerrno>
 #include <cstring>
 #include <cstring>
+#include <sstream>
+#include <iostream>
 
 
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
@@ -60,9 +62,17 @@ InterprocessSyncFile::do_lock(int cmd, short l_type) {
         umask(mode);
         umask(mode);
 
 
         if (fd_ == -1) {
         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());
         }
         }
     }
     }