diff options
-rw-r--r-- | sys/kern/uipc_socket.c | 8 | ||||
-rw-r--r-- | sys/sys/socketvar.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index d1ce038..19da509 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -368,6 +368,10 @@ socreate(dom, aso, type, proto, cred, td) knlist_init(&so->so_snd.sb_sel.si_note, SOCKBUF_MTX(&so->so_snd), NULL, NULL, NULL); so->so_count = 1; + /* + * Auto-sizing of socket buffers is managed by the protocols and + * the appropriate flags must be set in the pru_attach function. + */ error = (*prp->pr_usrreqs->pru_attach)(so, proto, td); if (error) { KASSERT(so->so_count == 1, ("socreate: so_count %d", @@ -442,6 +446,8 @@ sonewconn(head, connstatus) so->so_snd.sb_lowat = head->so_snd.sb_lowat; so->so_rcv.sb_timeo = head->so_rcv.sb_timeo; so->so_snd.sb_timeo = head->so_snd.sb_timeo; + so->so_rcv.sb_flags |= head->so_rcv.sb_flags & SB_AUTOSIZE; + so->so_snd.sb_flags |= head->so_snd.sb_flags & SB_AUTOSIZE; so->so_state |= connstatus; ACCEPT_LOCK(); if (connstatus) { @@ -2116,6 +2122,8 @@ sosetopt(so, sopt) error = ENOBUFS; goto bad; } + (sopt->sopt_name == SO_SNDBUF ? &so->so_snd : + &so->so_rcv)->sb_flags &= ~SB_AUTOSIZE; break; /* diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index 696418c..f7afcc3 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -128,6 +128,7 @@ struct socket { #define SB_NOINTR 0x40 /* operations not interruptible */ #define SB_AIO 0x80 /* AIO operations queued */ #define SB_KNOTE 0x100 /* kernel note attached */ +#define SB_AUTOSIZE 0x800 /* automatically size socket buffer */ void (*so_upcall)(struct socket *, void *, int); void *so_upcallarg; |