]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Correct win32 log messages about file locks (#953)
authorLuboš Luňák <l.lunak@centrum.cz>
Wed, 3 Nov 2021 20:19:54 +0000 (21:19 +0100)
committerGitHub <noreply@github.com>
Wed, 3 Nov 2021 20:19:54 +0000 (21:19 +0100)
src/Lockfile.cpp
src/Win32Util.cpp

index b1487dab2a049c608db4df3383dac39a7b98d83b..85fdd1b8c971854c4a7e62fa574bee333bb66749 100644 (file)
@@ -159,10 +159,6 @@ do_acquire_win32(const std::string& lockfile, uint32_t staleness_limit)
     }
 
     DWORD error = GetLastError();
-    LOG("lockfile_acquire: CreateFile {}: {} ({})",
-        lockfile,
-        Win32Util::error_message(error),
-        error);
     if (error == ERROR_PATH_NOT_FOUND) {
       // Directory doesn't exist?
       if (Util::create_dir(Util::dir_name(lockfile))) {
@@ -171,6 +167,11 @@ do_acquire_win32(const std::string& lockfile, uint32_t staleness_limit)
       }
     }
 
+    LOG("lockfile_acquire: CreateFile {}: {} ({})",
+        lockfile,
+        Win32Util::error_message(error),
+        error);
+
     // ERROR_SHARING_VIOLATION: lock already held.
     // ERROR_ACCESS_DENIED: maybe pending delete.
     if (error != ERROR_SHARING_VIOLATION && error != ERROR_ACCESS_DENIED) {
index 14e3e5b89fe4fdffb10069c7d2604f911397c6ed..e677107b7e128e876fdab1d73c5bd95a80ce4078 100644 (file)
@@ -70,6 +70,10 @@ error_message(DWORD error_code)
                    0,
                    nullptr);
   std::string message(buffer, size);
+  while (!message.empty()
+         && (message.back() == '\n' || message.back() == '\r')) {
+    message.pop_back();
+  }
   LocalFree(buffer);
   return message;
 }