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:
parent
59a481451b
commit
0814812e9b
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -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 ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user