mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Send keep alive messages to determine if client disconnected.
This commit is contained in:
parent
a0188122a0
commit
c056f3be41
@ -286,6 +286,7 @@ void Profiler::Worker()
|
||||
m_sock->Send( &welcome, sizeof( welcome ) );
|
||||
LZ4_resetStream( m_stream );
|
||||
|
||||
int keepAlive = 0;
|
||||
for(;;)
|
||||
{
|
||||
const auto status = Dequeue( token );
|
||||
@ -297,9 +298,29 @@ void Profiler::Worker()
|
||||
else if( status == QueueEmpty && serialStatus == QueueEmpty )
|
||||
{
|
||||
if( ShouldExit() ) break;
|
||||
if( m_bufferOffset != m_bufferStart ) CommitData();
|
||||
if( m_bufferOffset != m_bufferStart )
|
||||
{
|
||||
if( !CommitData() ) break;
|
||||
}
|
||||
if( keepAlive == 500 )
|
||||
{
|
||||
QueueItem ka;
|
||||
ka.hdr.type = QueueType::KeepAlive;
|
||||
AppendData( &ka, QueueDataSize[ka.hdr.idx] );
|
||||
if( !CommitData() ) break;
|
||||
|
||||
keepAlive = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
keepAlive++;
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
keepAlive = 0;
|
||||
}
|
||||
|
||||
while( m_sock->HasData() )
|
||||
{
|
||||
|
@ -1639,6 +1639,8 @@ void Worker::Process( const QueueItem& ev )
|
||||
case QueueType::Terminate:
|
||||
m_terminate = true;
|
||||
break;
|
||||
case QueueType::KeepAlive:
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user