first working version with page macros and new snd_copy
authorBill Joy <wnj@ucbvax.Berkeley.EDU>
Sat, 24 Oct 1981 02:07:56 +0000 (18:07 -0800)
committerBill Joy <wnj@ucbvax.Berkeley.EDU>
Sat, 24 Oct 1981 02:07:56 +0000 (18:07 -0800)
SCCS-vsn: sys/kern/uipc_mbuf.c 1.2
SCCS-vsn: sys/netinet/tcp_usrreq.c 1.8

usr/src/sys/kern/uipc_mbuf.c
usr/src/sys/netinet/tcp_usrreq.c

index 9e52140..7e8ffab 100644 (file)
@@ -1,4 +1,4 @@
-/* mbuf.c 1.6 81/10/21 */
+/* uipc_mbuf.c 1.2 81/10/23 */
 
 #include "../h/param.h"
 #include "../h/dir.h"
 
 #include "../h/param.h"
 #include "../h/dir.h"
@@ -82,6 +82,7 @@ COUNT(MBUFINIT);
        vmemall(&Netmap[0], 2, proc, CSYS);
        vmaccess(&Netmap[0], m, 2);
        for (i=0; i < NMBPG; i++) {
        vmemall(&Netmap[0], 2, proc, CSYS);
        vmaccess(&Netmap[0], m, 2);
        for (i=0; i < NMBPG; i++) {
+               m->m_off = 0;
                m_free(m);
                m++;
        }
                m_free(m);
                m++;
        }
@@ -112,6 +113,7 @@ COUNT(PG_ALLOC);
        bufs = n << 3;
        s = spl_imp();
        for (j=0; j < bufs; j++) {
        bufs = n << 3;
        s = spl_imp();
        for (j=0; j < bufs; j++) {
+               m->m_off = 0;
                m_free(m);
                m++;
        }
                m_free(m);
                m++;
        }
index feeb1f9..983391f 100644 (file)
@@ -1,4 +1,4 @@
-/* tcp_usrreq.c 1.7 81/10/22 */
+/* tcp_usrreq.c 1.8 81/10/23 */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -255,7 +255,9 @@ COUNT(T_CLOSE);
                m_freem(m);
                tp->t_rcv_unack = NULL;
        }
                m_freem(m);
                tp->t_rcv_unack = NULL;
        }
-       m_free(dtom(tp));
+       m = dtom(tp);
+       m->m_off = 0;
+       m_free(m);
        up->uc_tcb = NULL;
 
        /* lower buffer allocation and decrement host entry */
        up->uc_tcb = NULL;
 
        /* lower buffer allocation and decrement host entry */
@@ -286,50 +288,41 @@ sss_snd(tp, m0)
        seq_t last;
 
        last = tp->snd_off;
        seq_t last;
 
        last = tp->snd_off;
-
-       /* count number of mbufs in send data */
-
        for (m = n = m0; m != NULL; m = m->m_next) {
                up->uc_ssize++;
        for (m = n = m0; m != NULL; m = m->m_next) {
                up->uc_ssize++;
+               if (m->m_off > MSIZE)
+                       up->uc_ssize += NMBPG;
                last += m->m_len;
        }
                last += m->m_len;
        }
-
-       /* find end of send buffer and append data */
-
-       if ((m = up->uc_sbuf) != NULL) {                /* something in send buffer */
-               while (m->m_next != NULL) {             /* find the end */
+       if ((m = up->uc_sbuf) == NULL)
+               up->uc_sbuf = n;
+       else {
+               while (m->m_next != NULL) {
                        m = m->m_next;
                        last += m->m_len;
                }
                        m = m->m_next;
                        last += m->m_len;
                }
-               last += m->m_len;
-
-               /* if there's room in old buffer for new data, consolidate */
-
-               off = m->m_off + m->m_len;
-               while (n != NULL && (MSIZE - off) >= n->m_len) {
-                       bcopy((caddr_t)((int)n + n->m_off),
-                             (caddr_t)((int)m + off), n->m_len);
-                       m->m_len += n->m_len;
-                       off += n->m_len;
-                       up->uc_ssize--;
-                       n = m_free(n);
+               if (m->m_off <= MSIZE) {
+                       last += m->m_len;
+                       off = m->m_off + m->m_len;
+                       while (n && n->m_off <= MSIZE &&
+                           (MSIZE - off) >= n->m_len) {
+                               bcopy((caddr_t)((int)n + n->m_off),
+                                     (caddr_t)((int)m + off), n->m_len);
+                               m->m_len += n->m_len;
+                               off += n->m_len;
+                               up->uc_ssize--;
+                               n = m_free(n);
+                       }
                }
                m->m_next = n;
                }
                m->m_next = n;
-
-       } else          /* nothing in send buffer */
-               up->uc_sbuf = n;
-
-       if (up->uc_flags & UEOL) {              /* set EOL */
-               tp->snd_end = last;
        }
        }
-
-       if (up->uc_flags & UURG) {              /* urgent data */
+       if (up->uc_flags & UEOL)
+               tp->snd_end = last;
+       if (up->uc_flags & UURG) {
                tp->snd_urp = last+1;
                tp->tc_flags |= TC_SND_URG;
        }
                tp->snd_urp = last+1;
                tp->tc_flags |= TC_SND_URG;
        }
-
        send(tp);
        send(tp);
-
        return (SAME);
 }
 
        return (SAME);
 }