From: Joel Rosdahl Date: Sat, 9 May 2026 14:40:05 +0000 (+0200) Subject: fix: Make fallbacks in util::gmtime and util::localtime thread-safe X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ea4671eab111f8ffd714044fa4150a7bb07a4201;p=thirdparty%2Fccache.git fix: Make fallbacks in util::gmtime and util::localtime thread-safe --- diff --git a/src/ccache/util/time.cpp b/src/ccache/util/time.cpp index 30591eda..acc9f28c 100644 --- a/src/ccache/util/time.cpp +++ b/src/ccache/util/time.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Joel Rosdahl and other contributors +// Copyright (C) 2023-2026 Joel Rosdahl and other contributors // // See doc/authors.adoc for a complete list of contributors. // @@ -18,6 +18,8 @@ #include "time.hpp" +#include + namespace util { std::optional @@ -30,6 +32,8 @@ gmtime(std::optional time) return result; } #else + static std::mutex mutex; + std::lock_guard lock(mutex); struct tm* result = ::gmtime(×tamp); if (result) { return *result; @@ -48,6 +52,8 @@ localtime(std::optional time) return result; } #else + static std::mutex mutex; + std::lock_guard lock(mutex); struct tm* result = ::localtime(×tamp); if (result) { return *result;