From: Luboš Luňák Date: Wed, 3 Nov 2021 20:19:54 +0000 (+0100) Subject: fix: Correct win32 log messages about file locks (#953) X-Git-Tag: v4.5~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24f8ea1af3ceb15dad7687f31b6e8add210193d9;p=thirdparty%2Fccache.git fix: Correct win32 log messages about file locks (#953) --- diff --git a/src/Lockfile.cpp b/src/Lockfile.cpp index b1487dab2..85fdd1b8c 100644 --- a/src/Lockfile.cpp +++ b/src/Lockfile.cpp @@ -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) { diff --git a/src/Win32Util.cpp b/src/Win32Util.cpp index 14e3e5b89..e677107b7 100644 --- a/src/Win32Util.cpp +++ b/src/Win32Util.cpp @@ -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; }