Send listen port in broadcast message.

This commit is contained in:
Bartosz Taudul 2020-03-08 14:37:59 +01:00
parent 14c896573d
commit 127224acc6
2 changed files with 5 additions and 3 deletions

View File

@ -526,12 +526,13 @@ static uint64_t GetPid()
#endif
}
static BroadcastMessage& GetBroadcastMessage( const char* procname, size_t pnsz, int& len )
static BroadcastMessage& GetBroadcastMessage( const char* procname, size_t pnsz, int& len, int port )
{
static BroadcastMessage msg;
msg.broadcastVersion = BroadcastVersion;
msg.protocolVersion = ProtocolVersion;
msg.listenPort = port;
memcpy( msg.programName, procname, pnsz );
memset( msg.programName + pnsz, 0, WelcomeMessageProgramNameSize - pnsz );
@ -1247,7 +1248,7 @@ void Profiler::Worker()
#endif
int broadcastLen = 0;
auto& broadcastMsg = GetBroadcastMessage( procname, pnsz, broadcastLen );
auto& broadcastMsg = GetBroadcastMessage( procname, pnsz, broadcastLen, dataPort );
uint64_t lastBroadcast = 0;
// Connections loop.

View File

@ -10,7 +10,7 @@ namespace tracy
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
enum : uint32_t { ProtocolVersion = 28 };
enum : uint32_t { BroadcastVersion = 0 };
enum : uint32_t { BroadcastVersion = 1 };
using lz4sz_t = uint32_t;
@ -92,6 +92,7 @@ struct BroadcastMessage
{
uint32_t broadcastVersion;
uint32_t protocolVersion;
uint32_t listenPort;
uint32_t activeTime; // in seconds
char programName[WelcomeMessageProgramNameSize];
};