From 5c826c272301a01d40be10deab774402c80edf5d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 20 Sep 2020 22:15:10 +0200 Subject: [PATCH] Send signed active time in broadcast message. This allows special treatment of negative values. --- client/TracyProfiler.cpp | 3 ++- common/TracyProtocol.hpp | 4 ++-- profiler/src/main.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index e73bf4e2..97b0e3c5 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1390,7 +1390,8 @@ void Profiler::Worker() { lastBroadcast = t; const auto ts = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch() ).count(); - broadcastMsg.activeTime = uint32_t( ts - m_epoch ); + broadcastMsg.activeTime = int32_t( ts - m_epoch ); + assert( broadcastMsg.activeTime >= 0 ); m_broadcast->Send( broadcastPort, &broadcastMsg, broadcastLen ); } } diff --git a/common/TracyProtocol.hpp b/common/TracyProtocol.hpp index f706e70c..1a2c7ea5 100644 --- a/common/TracyProtocol.hpp +++ b/common/TracyProtocol.hpp @@ -10,7 +10,7 @@ namespace tracy constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; } enum : uint32_t { ProtocolVersion = 40 }; -enum : uint32_t { BroadcastVersion = 1 }; +enum : uint32_t { BroadcastVersion = 2 }; using lz4sz_t = uint32_t; @@ -111,7 +111,7 @@ struct BroadcastMessage uint32_t broadcastVersion; uint32_t protocolVersion; uint32_t listenPort; - uint32_t activeTime; // in seconds + int32_t activeTime; // in seconds char programName[WelcomeMessageProgramNameSize]; }; diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 2a3f1343..adee18f9 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -106,7 +106,7 @@ struct ClientData { int64_t time; uint32_t protocolVersion; - uint32_t activeTime; + int32_t activeTime; uint32_t port; std::string procName; std::string address;