Send host info in welcome message.

This commit is contained in:
Bartosz Taudul 2018-08-19 18:19:12 +02:00
parent 9c0e6620b3
commit bd76f4cd10
2 changed files with 5 additions and 0 deletions

View File

@ -448,6 +448,7 @@ void Profiler::Worker()
const auto pnsz = std::min<size_t>( strlen( procname ), WelcomeMessageProgramNameSize - 1 ); const auto pnsz = std::min<size_t>( strlen( procname ), WelcomeMessageProgramNameSize - 1 );
const auto hostinfo = GetHostInfo(); const auto hostinfo = GetHostInfo();
const auto hisz = std::min<size_t>( strlen( hostinfo ), WelcomeMessageHostInfoSize - 1 );
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 ) );
@ -467,6 +468,8 @@ void Profiler::Worker()
MemWrite( &welcome.onDemand, onDemand ); MemWrite( &welcome.onDemand, onDemand );
memcpy( welcome.programName, procname, pnsz ); memcpy( welcome.programName, procname, pnsz );
memset( welcome.programName + pnsz, 0, WelcomeMessageProgramNameSize - pnsz ); memset( welcome.programName + pnsz, 0, WelcomeMessageProgramNameSize - pnsz );
memcpy( welcome.hostInfo, hostinfo, hisz );
memset( welcome.hostInfo + hisz, 0, WelcomeMessageHostInfoSize - hisz );
moodycamel::ConsumerToken token( s_queue ); moodycamel::ConsumerToken token( s_queue );

View File

@ -28,6 +28,7 @@ enum ServerQuery : uint8_t
}; };
enum { WelcomeMessageProgramNameSize = 64 }; enum { WelcomeMessageProgramNameSize = 64 };
enum { WelcomeMessageHostInfoSize = 1024 };
#pragma pack( 1 ) #pragma pack( 1 )
@ -41,6 +42,7 @@ struct WelcomeMessage
uint64_t epoch; uint64_t epoch;
uint8_t onDemand; uint8_t onDemand;
char programName[WelcomeMessageProgramNameSize]; char programName[WelcomeMessageProgramNameSize];
char hostInfo[WelcomeMessageHostInfoSize];
}; };
enum { WelcomeMessageSize = sizeof( WelcomeMessage ) }; enum { WelcomeMessageSize = sizeof( WelcomeMessage ) };