lkml.org 
[lkml]   [2010]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [patch] pipe: add support for shrinking and growing pipes
On Mon, May 24, 2010 at 4:51 PM, Brian Bloniarz <bmb@athenacr.com> wrote:
> 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:
>
> set_rcvbuf:
>                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;
>                else
>                        sk->sk_rcvbuf = val * 2;
>                break;
>
> I'm guessing pipes don't have this kind of wrinkle.

Yes, all of the above is understood. It's exposing these details to
userspace that's weird...

--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface" http://blog.man7.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2010-05-24 17:47    [W:0.057 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site