1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-07 07:33:51 +00:00

Don't block when polling for broadcast messages.

This commit is contained in:
Bartosz Taudul 2020-09-20 22:06:28 +02:00
parent 59a481451b
commit 0814812e9b
3 changed files with 4 additions and 4 deletions

View File

@ -726,14 +726,14 @@ void UdpListen::Close()
m_sock = -1; m_sock = -1;
} }
const char* UdpListen::Read( size_t& len, IpAddress& addr ) const char* UdpListen::Read( size_t& len, IpAddress& addr, int timeout )
{ {
static char buf[2048]; static char buf[2048];
struct pollfd fd; struct pollfd fd;
fd.fd = (socket_t)m_sock; fd.fd = (socket_t)m_sock;
fd.events = POLLIN; fd.events = POLLIN;
if( poll( &fd, 1, 10 ) <= 0 ) return nullptr; if( poll( &fd, 1, timeout ) <= 0 ) return nullptr;
sockaddr sa; sockaddr sa;
socklen_t salen = sizeof( struct sockaddr ); socklen_t salen = sizeof( struct sockaddr );

View File

@ -139,7 +139,7 @@ public:
bool Listen( int port ); bool Listen( int port );
void Close(); void Close();
const char* Read( size_t& len, IpAddress& addr ); const char* Read( size_t& len, IpAddress& addr, int timeout );
UdpListen( const UdpListen& ) = delete; UdpListen( const UdpListen& ) = delete;
UdpListen( UdpListen&& ) = delete; UdpListen( UdpListen&& ) = delete;

View File

@ -505,7 +505,7 @@ static void DrawContents()
{ {
tracy::IpAddress addr; tracy::IpAddress addr;
size_t len; size_t len;
auto msg = broadcastListen->Read( len, addr ); auto msg = broadcastListen->Read( len, addr, 0 );
if( msg ) if( msg )
{ {
assert( len <= sizeof( tracy::BroadcastMessage ) ); assert( len <= sizeof( tracy::BroadcastMessage ) );