mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Allow changing tracy port in client.
This commit is contained in:
parent
140654961c
commit
e13cbf52fd
@ -1156,6 +1156,12 @@ void Profiler::Worker()
|
||||
|
||||
SetThreadName( "Tracy Profiler" );
|
||||
|
||||
#ifdef TRACY_PORT
|
||||
const auto port = TRACY_PORT;
|
||||
#else
|
||||
const auto port = 8086;
|
||||
#endif
|
||||
|
||||
while( m_timeBegin.load( std::memory_order_relaxed ) == 0 ) std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
|
||||
|
||||
rpmalloc_thread_initialize();
|
||||
@ -1198,7 +1204,7 @@ void Profiler::Worker()
|
||||
moodycamel::ConsumerToken token( GetQueue() );
|
||||
|
||||
ListenSocket listen;
|
||||
if( !listen.Listen( "8086", 8 ) )
|
||||
if( !listen.Listen( port, 8 ) )
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
@ -1215,7 +1221,7 @@ void Profiler::Worker()
|
||||
#ifndef TRACY_NO_BROADCAST
|
||||
m_broadcast = (UdpBroadcast*)tracy_malloc( sizeof( UdpBroadcast ) );
|
||||
new(m_broadcast) UdpBroadcast();
|
||||
if( !m_broadcast->Open( "255.255.255.255", "8086" ) )
|
||||
if( !m_broadcast->Open( "255.255.255.255", port ) )
|
||||
{
|
||||
m_broadcast->~UdpBroadcast();
|
||||
tracy_free( m_broadcast );
|
||||
@ -1256,7 +1262,7 @@ void Profiler::Worker()
|
||||
lastBroadcast = t;
|
||||
const auto ts = std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now().time_since_epoch() ).count();
|
||||
broadcastMsg.activeTime = uint32_t( ts - m_epoch );
|
||||
m_broadcast->Send( 8086, &broadcastMsg, broadcastLen );
|
||||
m_broadcast->Send( port, &broadcastMsg, broadcastLen );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ ListenSocket::~ListenSocket()
|
||||
if( m_sock != -1 ) Close();
|
||||
}
|
||||
|
||||
bool ListenSocket::Listen( const char* port, int backlog )
|
||||
bool ListenSocket::Listen( int port, int backlog )
|
||||
{
|
||||
assert( m_sock == -1 );
|
||||
|
||||
@ -291,7 +291,10 @@ bool ListenSocket::Listen( const char* port, int backlog )
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
|
||||
if( getaddrinfo( nullptr, port, &hints, &res ) != 0 ) return false;
|
||||
char portbuf[32];
|
||||
sprintf( portbuf, "%i", port );
|
||||
|
||||
if( getaddrinfo( nullptr, portbuf, &hints, &res ) != 0 ) return false;
|
||||
|
||||
m_sock = socket( res->ai_family, res->ai_socktype, res->ai_protocol );
|
||||
#if defined _WIN32 || defined __CYGWIN__
|
||||
@ -359,7 +362,7 @@ UdpBroadcast::~UdpBroadcast()
|
||||
if( m_sock != -1 ) Close();
|
||||
}
|
||||
|
||||
bool UdpBroadcast::Open( const char* addr, const char* port )
|
||||
bool UdpBroadcast::Open( const char* addr, int port )
|
||||
{
|
||||
assert( m_sock == -1 );
|
||||
|
||||
@ -370,7 +373,10 @@ bool UdpBroadcast::Open( const char* addr, const char* port )
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
|
||||
if( getaddrinfo( addr, port, &hints, &res ) != 0 ) return false;
|
||||
char portbuf[32];
|
||||
sprintf( portbuf, "%i", port );
|
||||
|
||||
if( getaddrinfo( addr, portbuf, &hints, &res ) != 0 ) return false;
|
||||
int sock = 0;
|
||||
for( ptr = res; ptr; ptr = ptr->ai_next )
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
ListenSocket();
|
||||
~ListenSocket();
|
||||
|
||||
bool Listen( const char* port, int backlog );
|
||||
bool Listen( int port, int backlog );
|
||||
Socket* Accept();
|
||||
void Close();
|
||||
|
||||
@ -71,7 +71,7 @@ public:
|
||||
UdpBroadcast();
|
||||
~UdpBroadcast();
|
||||
|
||||
bool Open( const char* addr, const char* port );
|
||||
bool Open( const char* addr, int port );
|
||||
void Close();
|
||||
|
||||
int Send( int port, const void* data, int len );
|
||||
|
Loading…
Reference in New Issue
Block a user