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
+18 -2
View File
@@ -201,6 +201,7 @@ Worker::Worker( const char* addr )
, m_pendingSourceLocation( 0 )
, m_pendingCallstackFrames( 0 )
, m_traceVersion( CurrentVersion )
, m_handshake( 0 )
{
m_data.sourceLocationExpand.push_back( 0 );
m_data.threadExpand.push_back( 0 );
@@ -224,6 +225,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
, m_crashed( false )
, m_stream( nullptr )
, m_buffer( nullptr )
, m_handshake( 0 )
{
m_data.threadExpand.push_back( 0 );
m_data.callstackPayload.push_back( nullptr );
@@ -1279,14 +1281,28 @@ void Worker::Exec()
if( m_sock.Connect( m_addr.c_str(), "8086" ) ) break;
}
m_sock.Send( HandshakeShibboleth, HandshakeShibbolethSize );
auto lz4buf = std::make_unique<char[]>( LZ4Size );
std::chrono::time_point<std::chrono::high_resolution_clock> t0;
uint64_t bytes = 0;
uint64_t decBytes = 0;
m_sock.Send( HandshakeShibboleth, HandshakeShibbolethSize );
uint32_t protocolVersion = ProtocolVersion;
m_sock.Send( &protocolVersion, sizeof( protocolVersion ) );
HandshakeStatus handshake;
if( !m_sock.Read( &handshake, sizeof( handshake ), &tv, ShouldExit ) ) goto close;
m_handshake.store( handshake, std::memory_order_relaxed );
switch( handshake )
{
case HandshakeWelcome:
break;
case HandshakeProtocolMismatch:
default:
goto close;
}
m_data.framesBase = m_data.frames.Retrieve( 0, [this] ( uint64_t name ) {
auto fd = m_slab.AllocInit<FrameData>();
fd->name = name;