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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user