Also no need to construct more than one welcome message.

This commit is contained in:
Bartosz Taudul 2017-10-17 21:55:40 +02:00
parent 5421164f33
commit 652dccd163

View File

@ -155,23 +155,8 @@ void Profiler::Worker()
const auto procname = GetProcessName(); const auto procname = GetProcessName();
const auto pnsz = std::min<size_t>( strlen( procname ), WelcomeMessageProgramNameSize - 1 ); const auto pnsz = std::min<size_t>( strlen( procname ), WelcomeMessageProgramNameSize - 1 );
moodycamel::ConsumerToken token( s_queue );
ListenSocket listen;
listen.Listen( "8086", 8 );
while( m_timeBegin.load( std::memory_order_relaxed ) == 0 ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); while( m_timeBegin.load( std::memory_order_relaxed ) == 0 ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
for(;;)
{
for(;;)
{
if( ShouldExit() ) return;
m_sock = listen.Accept();
if( m_sock ) break;
}
{
WelcomeMessage welcome; WelcomeMessage welcome;
#ifdef DISABLE_LZ4 #ifdef DISABLE_LZ4
// notify client that lz4 compression is disabled (too slow in debug builds) // notify client that lz4 compression is disabled (too slow in debug builds)
@ -188,9 +173,21 @@ void Profiler::Worker()
memcpy( welcome.programName, procname, pnsz ); memcpy( welcome.programName, procname, pnsz );
memset( welcome.programName + pnsz, 0, WelcomeMessageProgramNameSize - pnsz ); memset( welcome.programName + pnsz, 0, WelcomeMessageProgramNameSize - pnsz );
m_sock->Send( &welcome, sizeof( welcome ) ); moodycamel::ConsumerToken token( s_queue );
ListenSocket listen;
listen.Listen( "8086", 8 );
for(;;)
{
for(;;)
{
if( ShouldExit() ) return;
m_sock = listen.Accept();
if( m_sock ) break;
} }
m_sock->Send( &welcome, sizeof( welcome ) );
LZ4_resetStream( m_stream ); LZ4_resetStream( m_stream );
for(;;) for(;;)