diff --git a/lib/sockopt.c b/lib/sockopt.c index ed681710e5c7..2ce57b139f6d 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -23,8 +23,8 @@ void setsockopt_so_recvbuf(int sock, int size) { int orig_req = size; - while (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)) - == -1) + while (size && setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &size, + sizeof(size)) == -1) size /= 2; if (size != orig_req) @@ -37,8 +37,8 @@ void setsockopt_so_sendbuf(const int sock, int size) { int orig_req = size; - while (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) - == -1) + while (size && setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &size, + sizeof(size)) == -1) size /= 2; if (size != orig_req)