From 7300c2e46eb5d5ed249a66ef06021bae5bb043bf Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 11 Jan 2018 13:43:54 +0100 Subject: [PATCH] Fix TRACY_NO_EXIT behavior. Terminate event could be the first event that was sent. In such case server immediately closed the connection, as there was no outstanding data to receive. Fix by sending all data in the queue before sending terminate event. --- client/TracyProfiler.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index dc487c9e..9a08cb49 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -230,6 +230,25 @@ void Profiler::Worker() if( ShouldExit() ) break; } + for(;;) + { + const auto status = Dequeue( token ); + if( status == ConnectionLost ) + { + break; + } + else if( status == QueueEmpty ) + { + if( m_bufferOffset != m_bufferStart ) CommitData(); + break; + } + + while( m_sock->HasData() ) + { + if( !HandleServerQuery() ) break; + } + } + QueueItem terminate; terminate.hdr.type = QueueType::Terminate; if( !SendData( (const char*)&terminate, 1 ) ) return;