commit b2cfd5c199c3fbab956005bf4ed922cc826613ed parent 8bedd55b73dbdcc7c19f1286aa68b2712aa4c5fe Author: Michael Savage <mikejsavage@gmail.com> Date: Sat Sep 2 19:18:05 +0300 Use MSG_NOSIGNAL Diffstat:
platform_network.cc | | | 4 | ++-- |
unix_network.cc | | | 2 | ++ |
win32_network.cc | | | 2 | ++ |
diff --git a/platform_network.cc b/platform_network.cc @@ -146,7 +146,7 @@ void net_send( UDPSocket sock, const void * data, size_t len, const NetAddress & struct sockaddr_storage ss = netaddress_to_sockaddr( addr ); socklen_t ss_size = sockaddr_size( ss ); OSSocket fd = addr.type == NET_IPV4 ? sock.ipv4 : sock.ipv6; - ssize_t ok = sendto( fd, ( const char * ) data, checked_cast< int >( len ), 0, ( struct sockaddr * ) &ss, ss_size ); + ssize_t ok = sendto( fd, ( const char * ) data, checked_cast< int >( len ), NET_SEND_FLAGS, ( struct sockaddr * ) &ss, ss_size ); if( ok == SOCKET_ERROR ) { FATAL( "sendto" ); } @@ -192,7 +192,7 @@ bool net_new_tcp( TCPSocket * sock, const NetAddress & addr, NonblockingBool non } bool net_send( TCPSocket sock, const void * data, size_t len ) { - ssize_t sent = send( sock.fd, ( const char * ) data, len, 0 ); + ssize_t sent = send( sock.fd, ( const char * ) data, len, NET_SEND_FLAGS ); if( sent < 0 ) return false; return checked_cast< size_t >( sent ) == len; } diff --git a/unix_network.cc b/unix_network.cc @@ -12,6 +12,8 @@ #define closesocket close +static int NET_SEND_FLAGS = MSG_NOSIGNAL; + void net_init() { } void net_term() { } diff --git a/win32_network.cc b/win32_network.cc @@ -1,6 +1,8 @@ #include <winsock2.h> #include <ws2tcpip.h> +static int NET_SEND_FLAGS = 0; + void net_init() { WSADATA wsa_data; if( WSAStartup( MAKEWORD( 2, 2 ), &wsa_data ) == SOCKET_ERROR ) {