linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* setsockopt() doubles SO_RCVBUF
@ 2002-08-26 13:31 Anders K. Pedersen
  2002-08-27  7:54 ` Chris Wedgwood
  0 siblings, 1 reply; 2+ messages in thread
From: Anders K. Pedersen @ 2002-08-26 13:31 UTC (permalink / raw)
  To: linux-kernel

Hello,

In a project, I'm working on, I need to set the socket receive buffer
size, so I used
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, ...). To make sure, it worked
properly, I read the size back with getsockopt(fd, SOL_SOCKET,
SO_RCVBUF, ...). I was surprised to find, that the value read back was
always twice the size of, what I (tried to) set it to - up to twice the
size of rmem_max.

I found the cause of this behaviour in net/core/sock.c, which contains
the following lines of code in sock_setsockopt:

                case SO_RCVBUF:
                        /* Don't error on this BSD doesn't and if you
think
                           about it this is right. Otherwise apps have
to
                           play 'guess the biggest size' games.
RCVBUF/SNDBUF
                           are treated in BSD as hints */
                          
                        if (val > sysctl_rmem_max)
                                val = sysctl_rmem_max;

                        sk->userlocks |= SOCK_RCVBUF_LOCK;
                        /* FIXME: is this lower bound the right one? */
                        if ((val * 2) < SOCK_MIN_RCVBUF)
                                sk->rcvbuf = SOCK_MIN_RCVBUF;
                        else
                                sk->rcvbuf = (val * 2);
                        break;

Is it intentional, that val is doubled?

Regards,
Anders K. Pedersen

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: setsockopt() doubles SO_RCVBUF
  2002-08-26 13:31 setsockopt() doubles SO_RCVBUF Anders K. Pedersen
@ 2002-08-27  7:54 ` Chris Wedgwood
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Wedgwood @ 2002-08-27  7:54 UTC (permalink / raw)
  To: Anders K. Pedersen; +Cc: linux-kernel

On Mon, Aug 26, 2002 at 03:31:34PM +0200, Anders K. Pedersen wrote:

    Is it intentional, that val is doubled?

Yes.


  --cw

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-08-27  7:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-26 13:31 setsockopt() doubles SO_RCVBUF Anders K. Pedersen
2002-08-27  7:54 ` Chris Wedgwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).