From ceb474e0725ee14e1c3a2af293bcd976dce23c84 Mon Sep 17 00:00:00 2001 From: Che-Yu Wu Date: Wed, 25 Jan 2023 05:32:19 +0000 Subject: [PATCH] Wait on HasData condition to avoid infinite loop. Tracy worker resets the IsConnected to false when finishing the capture. If it finishes too quick, the waiting loop in capture.cpp might never see IsConnected = true. --- capture/src/capture.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/capture/src/capture.cpp b/capture/src/capture.cpp index 0a49c3f2..e8f1cda2 100644 --- a/capture/src/capture.cpp +++ b/capture/src/capture.cpp @@ -159,7 +159,7 @@ int main( int argc, char** argv ) printf( "Connecting to %s:%i...", address, port ); fflush( stdout ); tracy::Worker worker( address, port ); - while( !worker.IsConnected() ) + while( !worker.HasData() ) { const auto handshake = worker.GetHandshakeStatus(); if( handshake == tracy::HandshakeProtocolMismatch ) @@ -179,7 +179,6 @@ int main( int argc, char** argv ) } std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); } - while( !worker.HasData() ) std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); printf( "\nQueue delay: %s\nTimer resolution: %s\n", tracy::TimeToString( worker.GetDelay() ), tracy::TimeToString( worker.GetResolution() ) ); #ifdef _WIN32