Attached is a patch that fixes the following:

- The argument for setsockopt is an int, not a size_t. This breaks on
  64bit OS's causing the buffer not to be set (or triggers a kernel
  bug on AIX due to size_t being parsed as an int and setting the
  socket buffer to zero due to bad kernel error checking).
- Add a check to see if the socket buffer is large enough already,
  don't make it smaller if it is.

From Niklas Edmundsson


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22701 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2008-03-21 21:37:32 +00:00
parent 20fa0e0ba4
commit c008e1015f

View File

@@ -45,10 +45,24 @@ void
set_buffer_size(int fd, int read)
{
#if defined(SO_RCVBUF) && defined(SO_SNDBUF) && defined(HAVE_SETSOCKOPT)
size_t size = 4194304;
int size = 4194304;
int optname = read ? SO_RCVBUF : SO_SNDBUF;
#ifdef HAVE_GETSOCKOPT
int curr=0;
socklen_t optlen;
optlen = sizeof(curr);
if(getsockopt(fd, SOL_SOCKET, optname, (void *)&curr, &optlen) == 0) {
if(curr >= size) {
/* Already large enough */
return;
}
}
#endif /* HAVE_GETSOCKOPT */
while(size >= 131072 &&
setsockopt(fd, SOL_SOCKET, read ? SO_RCVBUF : SO_SNDBUF,
(void *)&size, sizeof(size)) < 0)
setsockopt(fd, SOL_SOCKET, optname, (void *)&size, sizeof(size)) < 0)
size /= 2;
#endif
}