1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Proper handling of disconnect request.

This commit is contained in:
Bartosz Taudul
2019-08-01 23:14:09 +02:00
parent 344d36086f
commit a4e7a341c0
7 changed files with 47 additions and 4 deletions
+32
View File
@@ -2064,6 +2064,9 @@ bool Profiler::HandleServerQuery()
case ServerQueryFrameName:
SendString( ptr, (const char*)ptr, QueueType::FrameName );
break;
case ServerQueryDisconnect:
HandleDisconnect();
return false;
default:
assert( false );
break;
@@ -2072,6 +2075,35 @@ bool Profiler::HandleServerQuery()
return true;
}
void Profiler::HandleDisconnect()
{
QueueItem terminate;
MemWrite( &terminate.hdr.type, QueueType::Terminate );
if( !SendData( (const char*)&terminate, 1 ) ) return;
for(;;)
{
if( m_sock->HasData() )
{
while( m_sock->HasData() )
{
if( !HandleServerQuery() ) return;
}
if( m_bufferOffset != m_bufferStart )
{
if( !CommitData() ) return;
}
}
else
{
if( m_bufferOffset != m_bufferStart )
{
if( !CommitData() ) return;
}
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
}
}
}
void Profiler::CalibrateTimer()
{
#ifdef TRACY_HW_TIMER