From: Jeffrey Altman Date: Sun, 11 Jan 2009 04:24:37 +0000 (+0000) Subject: rx-user-socket-buffer-sizes-20090110 X-Git-Tag: openafs-stable-1_4_12pre1~77 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=cdbfef3602c911c74b3e63e1beda22ffa0b5768d;p=packages%2Fo%2Fopenafs.git rx-user-socket-buffer-sizes-20090110 LICENSE MIT if the socket buffer size specified by the configuration is too large to be applied, do not drop down immediately to 32766 bytes. Instead try increasingly smaller values trying to find the largest one that works. use the same value for the send buf size as well. (cherry picked from commit 5b0e23567e1ed64f448bb3253ad90d39cad31271) Change-Id: I7cb1ded895458d099be5aeffc712a914193e18c0 Reviewed-on: http://gerrit.openafs.org/922 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/rx/rx_user.c b/src/rx/rx_user.c index 6630baaec..6c61ed4c1 100644 --- a/src/rx/rx_user.c +++ b/src/rx/rx_user.c @@ -151,15 +151,26 @@ rxi_GetHostUDPSocket(u_int ahost, u_short port) len1 = 32766; len2 = rx_UdpBufSize; - greedy = - (setsockopt - (socketFd, SOL_SOCKET, SO_RCVBUF, (char *)&len2, - sizeof(len2)) >= 0); - if (!greedy) { - len2 = 32766; /* fall back to old size... uh-oh! */ - } - greedy = + /* find the size closest to rx_UdpBufSize that will be accepted */ + while (!greedy && len2 > len1) { + greedy = + (setsockopt + (socketFd, SOL_SOCKET, SO_RCVBUF, (char *)&len2, + sizeof(len2)) >= 0); + if (!greedy) + len2 /= 2; + } + + /* but do not let it get smaller than 32K */ + if (len2 < len1) + len2 = len1; + + if (len1 < len2) + len1 = len2; + + + greedy = (setsockopt (socketFd, SOL_SOCKET, SO_SNDBUF, (char *)&len1, sizeof(len1)) >= 0)