Send program name in welcome message.

This commit is contained in:
Bartosz Taudul 2017-10-03 23:17:58 +02:00
parent 6485457518
commit cf07383db8
2 changed files with 10 additions and 0 deletions

View File

@ -114,6 +114,9 @@ void Profiler::Worker()
}
{
const auto procname = GetProcessName();
const auto pnsz = std::min<size_t>( strlen( procname ), WelcomeMessageProgramNameSize - 1 );
WelcomeMessage welcome;
#ifdef DISABLE_LZ4
// notify client that lz4 compression is disabled (too slow in debug builds)
@ -125,6 +128,8 @@ void Profiler::Worker()
welcome.timeBegin = m_timeBegin;
welcome.delay = m_delay;
welcome.resolution = m_resolution;
memcpy( welcome.programName, procname, pnsz );
memset( welcome.programName + pnsz, 0, WelcomeMessageProgramNameSize - pnsz );
m_sock->Send( &welcome, sizeof( welcome ) );
}

View File

@ -24,6 +24,8 @@ enum ServerQuery : uint8_t
ServerQuerySourceLocation,
};
enum { WelcomeMessageProgramNameSize = 64 };
#pragma pack( 1 )
struct WelcomeMessage
{
@ -32,9 +34,12 @@ struct WelcomeMessage
uint64_t timeBegin;
uint64_t delay;
uint64_t resolution;
char programName[WelcomeMessageProgramNameSize];
};
#pragma pack()
enum { WelcomeMessageSize = sizeof( WelcomeMessage ) };
}
#endif