From: Memphiz Date: Thu, 10 Apr 2014 18:30:30 +0000 (+0200) Subject: [socket] - disable linger by setting SO_LINGER to 0 seconds X-Git-Tag: upstream/1.9.6^2~42^2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=74b037ec4622347b518b68eb915cfb53330bede0;p=deb_libnfs.git [socket] - disable linger by setting SO_LINGER to 0 seconds --- diff --git a/lib/socket.c b/lib/socket.c index d025e07..aede89a 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -95,6 +95,14 @@ static void set_nonblocking(int fd) #endif //FIXME } +static void set_nolinger(int fd) +{ + struct linger lng; + lng.l_onoff = 1; + lng.l_linger = 0; + setsockopt(fd, SOL_SOCKET, SO_LINGER, &lng, sizeof(lng)); +} + #ifdef HAVE_NETINET_TCP_H int set_tcp_sockopt(int sockfd, int optname, int value) { @@ -504,6 +512,7 @@ static int rpc_connect_sockaddr_async(struct rpc_context *rpc, struct sockaddr_s } set_nonblocking(rpc->fd); + set_nolinger(rpc->fd); if (connect(rpc->fd, (struct sockaddr *)s, socksize) != 0 && errno != EINPROGRESS) { rpc_set_error(rpc, "connect() to server failed. %s(%d)", strerror(errno), errno);