use setsockopt to limit read() block time and so to prevent linux

version from being unkillable when relay crashes at the wrong time.
This commit is contained in:
Eric House 2012-08-13 06:44:16 -07:00
parent 25e65d3e6f
commit c98bbe2b9a

View file

@ -728,6 +728,10 @@ linux_init_relay_socket( CommonGlobals* cGlobals, const CommsAddrRec* addrRec )
if ( 0 == connect( sock, (const struct sockaddr*)&to_sock,
sizeof(to_sock) ) ) {
cGlobals->socket = sock;
struct timeval tv = {0};
tv.tv_sec = 15;
setsockopt( sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv) );
} else {
close( sock );
sock = -1;