From 4dd9c4889ed621244cd7cb5039d68f4d86a824bb Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Thu, 21 Jan 2021 14:25:20 -0800 Subject: [PATCH] Revert "Make Profiler::active_profiler a unique pointer" and add comment --- flow/Profiler.actor.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/flow/Profiler.actor.cpp b/flow/Profiler.actor.cpp index fb6782321a..efcfbbd585 100644 --- a/flow/Profiler.actor.cpp +++ b/flow/Profiler.actor.cpp @@ -25,7 +25,6 @@ #ifdef __linux__ #include -#include #include #include #include @@ -125,7 +124,7 @@ struct Profiler { OutputBuffer* output_buffer; Future actor; sigset_t profilingSignals; - static std::unique_ptr active_profiler; + static Profiler* active_profiler; BinaryWriter environmentInfoWriter; INetwork* network; timer_t periodicTimer; @@ -257,7 +256,8 @@ struct Profiler { } }; -std::unique_ptr Profiler::active_profiler; +// Outlives main +Profiler* Profiler::active_profiler = nullptr; std::string findAndReplace( std::string const& fn, std::string const& symbol, std::string const& value ) { auto i = fn.find(symbol); @@ -283,12 +283,14 @@ void startProfiling(INetwork* network, Optional maybePeriod /*= {}*/, Optio outputFile = findAndReplace(findAndReplace(findAndReplace(outputFile, "%ADDRESS%", findAndReplace(network->getLocalAddress().toString(), ":", ".")), "%PID%", format("%d", getpid())), "%TID%", format("%llx", (long long)sys_gettid())); if (!Profiler::active_profiler) - Profiler::active_profiler = std::make_unique( period, outputFile, network ); + Profiler::active_profiler = new Profiler( period, outputFile, network ); } void stopProfiling() { if (Profiler::active_profiler) { - Profiler::active_profiler.reset(); + Profiler *p = Profiler::active_profiler; + Profiler::active_profiler = nullptr; + delete p; } }