1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-06 23:23:53 +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;
}
const char* UdpListen::Read( size_t& len, IpAddress& addr )
const char* UdpListen::Read( size_t& len, IpAddress& addr, int timeout )
{
static char buf[2048];
struct pollfd fd;
fd.fd = (socket_t)m_sock;
fd.events = POLLIN;
if( poll( &fd, 1, 10 ) <= 0 ) return nullptr;
if( poll( &fd, 1, timeout ) <= 0 ) return nullptr;
sockaddr sa;
socklen_t salen = sizeof( struct sockaddr );

View File

@ -139,7 +139,7 @@ public:
bool Listen( int port );
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( UdpListen&& ) = delete;

View File

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