[lkml]   [2010]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [patch] pipe: add support for shrinking and growing pipes
On 05/24/2010 03:28 AM, Michael Kerrisk wrote:
> Actually, SO_*BUF is pretty weird. It returns double what was
> supplied. It's not simply a matter of rounding up: it always doubles
> what was supplied.

Rationale in net/core/sock.c:

sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
* We double it on the way in to account for
* "struct sk_buff" etc. overhead. Applications
* assume that the SO_RCVBUF setting they make will
* allow that much actual data to be received on that
* socket.
* Applications are unaware that "struct sk_buff" and
* other overheads allocate from the receive buffer
* during socket buffer allocation.
* And after considering the possible alternatives,
* returning the value we actually used in getsockopt
* is the most desirable behavior.
if ((val * 2) < SOCK_MIN_RCVBUF)
sk->sk_rcvbuf = SOCK_MIN_RCVBUF;
sk->sk_rcvbuf = val * 2;

I'm guessing pipes don't have this kind of wrinkle.

 \ /
  Last update: 2010-05-24 16:55    [W:0.073 / U:5.432 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site