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

Send protocol version to verify handshake.

This commit is contained in:
Bartosz Taudul
2018-09-09 19:28:53 +02:00
parent db1d7d2c92
commit 984a711666
6 changed files with 85 additions and 3 deletions
+22 -1
View File
@@ -919,13 +919,31 @@ void Profiler::Worker()
tv.tv_usec = 0;
char shibboleth[HandshakeShibbolethSize];
const auto res = m_sock->ReadRaw( shibboleth, HandshakeShibbolethSize, &tv );
auto res = m_sock->ReadRaw( shibboleth, HandshakeShibbolethSize, &tv );
if( !res || memcmp( shibboleth, HandshakeShibboleth, HandshakeShibbolethSize ) != 0 )
{
m_sock->~Socket();
tracy_free( m_sock );
continue;
}
uint32_t protocolVersion;
res = m_sock->ReadRaw( &protocolVersion, sizeof( protocolVersion ), &tv );
if( !res )
{
m_sock->~Socket();
tracy_free( m_sock );
continue;
}
if( protocolVersion != ProtocolVersion )
{
HandshakeStatus status = HandshakeProtocolMismatch;
m_sock->Send( &status, sizeof( status ) );
m_sock->~Socket();
tracy_free( m_sock );
continue;
}
}
#ifdef TRACY_ON_DEMAND
@@ -933,6 +951,9 @@ void Profiler::Worker()
m_isConnected.store( true, std::memory_order_relaxed );
#endif
HandshakeStatus handshake = HandshakeWelcome;
m_sock->Send( &handshake, sizeof( handshake ) );
LZ4_resetStream( m_stream );
m_sock->Send( &welcome, sizeof( welcome ) );