Subject: small SO_SNDBUF fix (tcp_output.c 1.85)
To: None <tech-net@netbsd.org>
From: Sean Boudreau <seanb@qnx.com>
List: tech-net
Date: 11/29/2002 09:37:40
Hi:

I don't think it catches all cases.  Consider the case where
so_snd.sb_hiwat / 2 is sent but not acked (delayed), an in
progress write finishes (uio->resid -> 0) but doesn't fill the
send buffer (so_snd.sb_hiwat - so_snd.sb_cc < so_snd.sb_lowat).
The next write will then block in soreceive().  Maybe:

Index: netinet/tcp_output.c
===================================================================
RCS file: /cvsroot/syssrc/sys/netinet/tcp_output.c,v
retrieving revision 1.88
diff -c -r1.88 tcp_output.c
*** netinet/tcp_output.c        2002/11/24 10:51:56     1.88
--- netinet/tcp_output.c        2002/11/29 14:34:35
***************
*** 366,372 ****
         * transmit.
         */
        if (so)
!               *txsegsizep = min(so->so_snd.sb_hiwat >> 1, *txsegsizep);
        *rxsegsizep = min(tp->t_ourmss - optlen, size);

        if (*txsegsizep != tp->t_segsz) {
--- 366,372 ----
         * transmit.
         */
        if (so)
!               *txsegsizep = min((so->so_snd.sb_hiwat - so_snd.sb_lowat) >> 1, *txsegsizep);
        *rxsegsizep = min(tp->t_ourmss - optlen, size);

        if (*txsegsizep != tp->t_segsz) {