prevent inner loop in sosend from queuing more than "space" bytes;
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Fri, 30 Sep 1983 03:23:09 +0000 (19:23 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Fri, 30 Sep 1983 03:23:09 +0000 (19:23 -0800)
temporary fix to prevent 64K writes from crashing us.

SCCS-vsn: sys/kern/uipc_socket.c 6.2

usr/src/sys/kern/uipc_socket.c

index 30151a5..ea5bf11 100644 (file)
@@ -1,4 +1,4 @@
-/*     uipc_socket.c   6.2     83/09/28        */
+/*     uipc_socket.c   6.2     83/09/29        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -280,6 +280,7 @@ sosend(so, nam, uio, flags, rights)
        register struct mbuf *m, **mp = &top;
        register int space;
        int len, error = 0, s, dontroute;
        register struct mbuf *m, **mp = &top;
        register int space;
        int len, error = 0, s, dontroute;
+       struct sockbuf sendtempbuf;
 
        if (sosendallatonce(so) && uio->uio_resid > so->so_snd.sb_hiwat)
                return (EMSGSIZE);
 
        if (sosendallatonce(so) && uio->uio_resid > so->so_snd.sb_hiwat)
                return (EMSGSIZE);
@@ -343,6 +344,12 @@ again:
                }
        }
        splx(s);
                }
        }
        splx(s);
+       /*
+        * Temporary kludge-- don't want to update so_snd in this loop
+        * (will be done when sent), but need to recalculate
+        * space on each iteration.  For now, copy so_snd into a tmp.
+        */
+       sendtempbuf = so->so_snd;
        while (uio->uio_resid > 0 && space > 0) {
                register struct iovec *iov = uio->uio_iov;
 
        while (uio->uio_resid > 0 && space > 0) {
                register struct iovec *iov = uio->uio_iov;
 
@@ -377,8 +384,10 @@ nopages:
                mp = &m->m_next;
                if (flags & MSG_OOB)
                        space -= len;
                mp = &m->m_next;
                if (flags & MSG_OOB)
                        space -= len;
-               else
-                       space = sbspace(&so->so_snd);
+               else {
+                       sballoc(&sendtempbuf, m);
+                       space = sbspace(&sendtempbuf);
+               }
        }
        goto again;
 
        }
        goto again;