From 034340aa9f359b248146ac14653fabfc28cd276e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 26 Aug 2022 13:14:04 +0200 Subject: [PATCH] Fix potential duplicate activity IDs in forked child processes --- src/libutil/logging.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc index a6b7da9f5..a8ab78546 100644 --- a/src/libutil/logging.cc +++ b/src/libutil/logging.cc @@ -130,11 +130,11 @@ Logger * makeSimpleLogger(bool printBuildLogs) return new SimpleLogger(printBuildLogs); } -std::atomic nextId{(uint64_t) getpid() << 32}; +std::atomic nextId{0}; Activity::Activity(Logger & logger, Verbosity lvl, ActivityType type, const std::string & s, const Logger::Fields & fields, ActivityId parent) - : logger(logger), id(nextId++) + : logger(logger), id(nextId++ + (((uint64_t) getpid()) << 32)) { logger.startActivity(id, lvl, type, s, fields, parent); }