rename raw imp stuff and add in raw pup
[unix-history] / usr / src / sys / kern / uipc_pipe.c
index e6fdbe7..f1aa97c 100644 (file)
@@ -1,4 +1,4 @@
-/*     uipc_pipe.c     4.5     81/11/21        */
+/*     uipc_pipe.c     4.10    81/12/02        */
 
 #include "../h/param.h"
 #include "../h/dir.h"
 
 #include "../h/param.h"
 #include "../h/dir.h"
@@ -7,7 +7,7 @@
 #include "../h/protosw.h"
 #include "../h/socket.h"
 #include "../h/socketvar.h"
 #include "../h/protosw.h"
 #include "../h/socket.h"
 #include "../h/socketvar.h"
-#include "../net/inet_systm.h"         /* XXX */
+#include "../net/in_systm.h"           /* XXX */
 
 int    piusrreq();
 #define        PIPSIZ  4096
 
 int    piusrreq();
 #define        PIPSIZ  4096
@@ -16,9 +16,9 @@ int   piusrreq();
  * Code for pipes and other loopback protocols (single machine, that is.)
  */
 struct protosw pipeproto = {
  * Code for pipes and other loopback protocols (single machine, that is.)
  */
 struct protosw pipeproto = {
-       SOCK_STREAM,    PF_LOCAL,       0,              PR_CONNREQUIRED|PR_WANTRCVD,
+       SOCK_STREAM,    PF_UNIX,        0,              PR_CONNREQUIRED|PR_WANTRCVD,
        0,              0,              0,              0,
        0,              0,              0,              0,
-       piusrreq,       0,              0,
+       piusrreq,
        0,              0,              0,              0
 };
 
        0,              0,              0,              0
 };
 
@@ -31,7 +31,7 @@ piconnect(wso, rso)
 {
 
 COUNT(PICONNECT);
 {
 
 COUNT(PICONNECT);
-       if (m_reserve(PIPSIZ) == 0) {
+       if (m_reserve(PIPSIZ*2/MSIZE) == 0) {
                u.u_error = ENOBUFS;
                return (0);
        }
                u.u_error = ENOBUFS;
                return (0);
        }
@@ -78,6 +78,7 @@ COUNT(PIUSRREQ);
                if (so2 == 0)
                        return (ENOTCONN);
                so->so_pcb = 0;
                if (so2 == 0)
                        return (ENOTCONN);
                so->so_pcb = 0;
+               so2->so_pcb = 0;
                soisdisconnected(so);
                soisdisconnected(so2);
                break;
                soisdisconnected(so);
                soisdisconnected(so2);
                break;
@@ -93,10 +94,6 @@ COUNT(PIUSRREQ);
                        break;
 #define        rcv (&so->so_rcv)
 #define snd (&so2->so_snd)
                        break;
 #define        rcv (&so->so_rcv)
 #define snd (&so2->so_snd)
-/*
-printf("pru_rcvd in: ");
-psndrcv(snd, rcv);
-*/
                /*
                 * Transfer resources back to send port
                 * and wakeup any waiting to write.
                /*
                 * Transfer resources back to send port
                 * and wakeup any waiting to write.
@@ -105,10 +102,6 @@ psndrcv(snd, rcv);
                rcv->sb_mbmax = rcv->sb_mbcnt;
                snd->sb_hiwat += rcv->sb_hiwat - rcv->sb_cc;
                rcv->sb_hiwat = rcv->sb_cc;
                rcv->sb_mbmax = rcv->sb_mbcnt;
                snd->sb_hiwat += rcv->sb_hiwat - rcv->sb_cc;
                rcv->sb_hiwat = rcv->sb_cc;
-/*
-printf("pru_rcvd out: ");
-psndrcv(snd, rcv);
-*/
                sbwakeup(snd);
 #undef snd
 #undef rcv
                sbwakeup(snd);
 #undef snd
 #undef rcv
@@ -117,25 +110,19 @@ psndrcv(snd, rcv);
        case PRU_SEND:
 #define        rcv (&so2->so_rcv)
 #define        snd (&so->so_snd)
        case PRU_SEND:
 #define        rcv (&so2->so_rcv)
 #define        snd (&so->so_snd)
+               if (so2 == 0)
+                       panic("pipe send");
                /*
                 * Send to paired receive port, and then
                 * give it enough resources to hold what it already has.
                 * Wake up readers.
                 */
                /*
                 * Send to paired receive port, and then
                 * give it enough resources to hold what it already has.
                 * Wake up readers.
                 */
-/*
-printf("pru_send in: ");
-psndrcv(snd, rcv);
-*/
                sbappend(rcv, m);
                snd->sb_mbmax -= rcv->sb_mbcnt - rcv->sb_mbmax;
                rcv->sb_mbmax = rcv->sb_mbcnt;
                snd->sb_hiwat -= rcv->sb_cc - rcv->sb_hiwat;
                rcv->sb_hiwat = rcv->sb_cc;
                sbwakeup(rcv);
                sbappend(rcv, m);
                snd->sb_mbmax -= rcv->sb_mbcnt - rcv->sb_mbmax;
                rcv->sb_mbmax = rcv->sb_mbcnt;
                snd->sb_hiwat -= rcv->sb_cc - rcv->sb_hiwat;
                rcv->sb_hiwat = rcv->sb_cc;
                sbwakeup(rcv);
-/*
-printf("pru_send out: ");
-psndrcv(snd, rcv);
-*/
 #undef snd
 #undef rcv
                break;
 #undef snd
 #undef rcv
                break;