From 0814812e9b3db4ace9e71f63c654424f109c7ba4 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 20 Sep 2020 22:06:28 +0200 Subject: [PATCH] Don't block when polling for broadcast messages. --- common/TracySocket.cpp | 4 ++-- common/TracySocket.hpp | 2 +- profiler/src/main.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/TracySocket.cpp b/common/TracySocket.cpp index 07ed3cab..0d666a84 100644 --- a/common/TracySocket.cpp +++ b/common/TracySocket.cpp @@ -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 ); diff --git a/common/TracySocket.hpp b/common/TracySocket.hpp index bb4bd3f9..f9f618f2 100644 --- a/common/TracySocket.hpp +++ b/common/TracySocket.hpp @@ -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; diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 66fd2468..4b991274 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -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 ) );