X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/6294d633e80db8e89697db796e6f6025d5af0cae..ad7871609881e73855d0b04da49b486cd93efca7:/usr/src/sys/kern/uipc_socket2.c diff --git a/usr/src/sys/kern/uipc_socket2.c b/usr/src/sys/kern/uipc_socket2.c index b1a507b399..d4af592d79 100644 --- a/usr/src/sys/kern/uipc_socket2.c +++ b/usr/src/sys/kern/uipc_socket2.c @@ -1,10 +1,36 @@ /* - * Copyright (c) 1982, 1986, 1988, 1990 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1982, 1986, 1988, 1990, 1993 + * The Regents of the University of California. All rights reserved. * - * %sccs.include.redist.c% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * @(#)uipc_socket2.c 7.19 (Berkeley) %G% + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93 */ #include @@ -407,13 +433,19 @@ sbappend(sb, m) struct sockbuf *sb; struct mbuf *m; { - register struct mbuf *n, *n0; + register struct mbuf *n; if (m == 0) return; if (n = sb->sb_mb) { while (n->m_nextpkt) n = n->m_nextpkt; + do { + if (n->m_flags & M_EOR) { + sbappendrecord(sb, m); /* XXXXXX!!!! */ + return; + } + } while (n->m_next && (n = n->m_next)); } sbcompress(sb, m, n); } @@ -467,6 +499,10 @@ sbappendrecord(sb, m0) sb->sb_mb = m0; m = m0->m_next; m0->m_next = 0; + if (m && (m0->m_flags & M_EOR)) { + m0->m_flags &= ~M_EOR; + m->m_flags |= M_EOR; + } sbcompress(sb, m, m0); } @@ -501,10 +537,16 @@ sbinsertoob(sb, m0) * Put the first mbuf on the queue. * Note this permits zero length records. */ + sballoc(sb, m0); m0->m_nextpkt = *mp; *mp = m0; - for (m = m0; m; m = m->m_next) - sballoc(sb, m); + m = m0->m_next; + m0->m_next = 0; + if (m && (m0->m_flags & M_EOR)) { + m0->m_flags &= ~M_EOR; + m->m_flags |= M_EOR; + } + sbcompress(sb, m, m0); } /* @@ -519,7 +561,7 @@ sbappendaddr(sb, asa, m0, control) struct mbuf *m0, *control; { register struct mbuf *m, *n; - int space = asa->sa_len, eor = 0; + int space = asa->sa_len; if (m0 && (m0->m_flags & M_PKTHDR) == 0) panic("sbappendaddr"); @@ -544,11 +586,8 @@ panic("sbappendaddr"); else control = m0; m->m_next = control; - for (n = m; n; n = n->m_next) { - eor |= n->m_flags & M_EOR; + for (n = m; n; n = n->m_next) sballoc(sb, n); - } - m->m_flags |= eor; if (n = sb->sb_mb) { while (n->m_nextpkt) n = n->m_nextpkt; @@ -563,7 +602,7 @@ sbappendcontrol(sb, m0, control) struct mbuf *control, *m0; { register struct mbuf *m, *n; - int space = 0, eor = 0; + int space = 0; if (control == 0) panic("sbappendcontrol"); @@ -578,11 +617,8 @@ sbappendcontrol(sb, m0, control) if (space > sbspace(sb)) return (0); n->m_next = m0; /* concatenate data to control */ - for (m = control; m; m = m->m_next) { - eor |= m->m_flags & M_EOR; + for (m = control; m; m = m->m_next) sballoc(sb, m); - } - control->m_flags |= eor; if (n = sb->sb_mb) { while (n->m_nextpkt) n = n->m_nextpkt; @@ -597,29 +633,23 @@ sbappendcontrol(sb, m0, control) * buffer sb following mbuf n. If n * is null, the buffer is presumed empty. */ -sbcompress(sb, m, n0) +sbcompress(sb, m, n) register struct sockbuf *sb; - register struct mbuf *m; - struct mbuf *n0; + register struct mbuf *m, *n; { - register struct mbuf *n = n0; register int eor = 0; + register struct mbuf *o; - if (n) { - if (n->m_flags & M_EOR) - n = 0; - else while (n->m_next) - n = n->m_next; - } while (m) { eor |= m->m_flags & M_EOR; - if (m->m_len == 0) { - if (eor == 0 || m->m_next || n) { - m = m_free(m); - continue; - } + if (m->m_len == 0 && + (eor == 0 || + (((o = m->m_next) || (o = n)) && + o->m_type == m->m_type))) { + m = m_free(m); + continue; } - if (n && (n->m_flags & M_EXT) == 0 && + if (n && (n->m_flags & (M_EXT | M_EOR)) == 0 && (n->m_data + n->m_len + m->m_len) < &n->m_dat[MLEN] && n->m_type == m->m_type) { bcopy(mtod(m, caddr_t), mtod(n, caddr_t) + n->m_len, @@ -629,25 +659,21 @@ sbcompress(sb, m, n0) m = m_free(m); continue; } - if (n == 0) { - if (n0) - n0->m_nextpkt = m; - else - sb->sb_mb = m; - n0 = m; - } else + if (n) n->m_next = m; + else + sb->sb_mb = m; sballoc(sb, m); n = m; - /*m->m_flags &= ~M_EOR;*/ + m->m_flags &= ~M_EOR; m = m->m_next; n->m_next = 0; } if (eor) { - if (n0) - n0->m_flags |= eor; + if (n) + n->m_flags |= eor; else - panic("sbcompress"); + printf("semi-panic: sbcompress\n"); } }