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.
This commit is contained in:
Bartosz Taudul 2018-01-11 13:43:54 +01:00
parent 1cb12f74c4
commit 7300c2e46e

View File

@ -230,6 +230,25 @@ void Profiler::Worker()
if( ShouldExit() ) break; 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; QueueItem terminate;
terminate.hdr.type = QueueType::Terminate; terminate.hdr.type = QueueType::Terminate;
if( !SendData( (const char*)&terminate, 1 ) ) return; if( !SendData( (const char*)&terminate, 1 ) ) return;