mirror of
https://github.com/wolfpld/tracy.git
synced 2026-08-15 23:59:47 +00:00
Set TCP_NODELAY on profiler data channel.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
# include <errno.h>
|
||||
# include <fcntl.h>
|
||||
# include <netinet/in.h>
|
||||
# include <netinet/tcp.h>
|
||||
# include <netdb.h>
|
||||
# include <unistd.h>
|
||||
# include <poll.h>
|
||||
@@ -70,6 +71,18 @@ void InitWinSock()
|
||||
#endif
|
||||
|
||||
|
||||
static void SetNoDelay( int sock )
|
||||
{
|
||||
#ifdef _WIN32
|
||||
unsigned long val = 1;
|
||||
setsockopt( sock, IPPROTO_TCP, TCP_NODELAY, (const char*)&val, sizeof( val ) );
|
||||
#else
|
||||
int val = 1;
|
||||
setsockopt( sock, IPPROTO_TCP, TCP_NODELAY, &val, sizeof( val ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
constexpr size_t BufSize = 128 * 1024;
|
||||
|
||||
Socket::Socket()
|
||||
@@ -150,6 +163,7 @@ bool Socket::Connect( const char* addr, uint16_t port )
|
||||
int flags = fcntl( m_connSock, F_GETFL, 0 );
|
||||
fcntl( m_connSock, F_SETFL, flags & ~O_NONBLOCK );
|
||||
#endif
|
||||
SetNoDelay( m_connSock );
|
||||
m_sock.store( m_connSock, std::memory_order_relaxed );
|
||||
freeaddrinfo( m_res );
|
||||
m_ptr = nullptr;
|
||||
@@ -218,7 +232,7 @@ bool Socket::Connect( const char* addr, uint16_t port )
|
||||
int flags = fcntl( sock, F_GETFL, 0 );
|
||||
fcntl( sock, F_SETFL, flags & ~O_NONBLOCK );
|
||||
#endif
|
||||
|
||||
SetNoDelay( sock );
|
||||
m_sock.store( sock, std::memory_order_relaxed );
|
||||
return true;
|
||||
}
|
||||
@@ -529,6 +543,8 @@ Socket* ListenSocket::Accept()
|
||||
setsockopt( sock, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof( val ) );
|
||||
#endif
|
||||
|
||||
SetNoDelay( sock );
|
||||
|
||||
auto ptr = (Socket*)tracy_malloc( sizeof( Socket ) );
|
||||
new(ptr) Socket( sock );
|
||||
return ptr;
|
||||
|
||||
Reference in New Issue
Block a user