Skip to content

Commit

Permalink
util: Avoid concurrent writes to log file
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed Aug 25, 2023
1 parent ba138e8 commit f287b99
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/util/util_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using PFN_wineDbgOutput = int(__cdecl*)(const char*);

static PFN_wineDbgOutput wineDbgOutput = nullptr;
static std::mutex fileStreamMutex;

namespace dxvk::log {
void print(const std::string& message) {
Expand Down Expand Up @@ -56,7 +57,9 @@ namespace dxvk::log {
return;

print(message);
if (filestream)
if (filestream) {
std::scoped_lock lock(fileStreamMutex);
filestream << message << std::endl;
}
}
}

0 comments on commit f287b99

Please sign in to comment.