From 97af757c6c385916f7f4dc4c086016e9a9eb98cd Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 21 Dec 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-12-21 --- port/devip.c | 21 +++++++++++++++++++++ port/devscsi.c | 2 +- port/ipdat.h | 3 +++ port/tcpinput.c | 5 +++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/port/devip.c b/port/devip.c index de6430da9aa299c0f73d99a638879bc33648eb5d..4829492cbff712a0a37d98eef26dcb4dbbf9e1d2 100644 --- a/port/devip.c +++ b/port/devip.c @@ -604,6 +604,11 @@ tcpstiput(Queue *q, Block *bp) PUTNEXT(q, bp); } +tcproominq(void *a) +{ + return !((Tcpctl *)a)->sndfull; +} + void tcpstoput(Queue *q, Block *bp) { @@ -637,6 +642,20 @@ tcpstoput(Queue *q, Block *bp) case Syn_received: case Established: case Close_wait: + /* + * Process flow control + */ + if(tcb->sndfull){ + qlock(&tcb->sndrlock); + if(waserror()) { + qunlock(&tcb->sndrlock); + nexterror(); + } + sleep(&tcb->sndr, tcproominq, tcb); + poperror(); + qunlock(&tcb->sndrlock); + } + /* * Push data */ @@ -646,6 +665,8 @@ tcpstoput(Queue *q, Block *bp) nexterror(); } tcb->sndcnt += blen(bp); + if(tcb->sndcnt > Streamhi) + tcb->sndfull = 1; if(tcb->sndq == 0) tcb->sndq = bp; else { diff --git a/port/devscsi.c b/port/devscsi.c index 82fa18c1969b009013229bd3c7c6d4137f290251..d6f0a83c28f7a0cc2a0a6b63bc97d02df551cf9d 100644 --- a/port/devscsi.c +++ b/port/devscsi.c @@ -8,7 +8,7 @@ #define DPRINT if(debug)kprint -#define DATASIZE (32*512) +#define DATASIZE (64*512) static Scsi staticcmd; /* BUG: should be one per scsi device */ diff --git a/port/ipdat.h b/port/ipdat.h index a22155e2af9b6d6494f0c7981d2476977efb5d22..7ec2de425198ef4de2c7cedec6bfb581dc43d37b 100644 --- a/port/ipdat.h +++ b/port/ipdat.h @@ -240,6 +240,9 @@ struct Tctl Block *sndq; /* List of data going out */ ulong sndcnt; /* Amount of data in send queue */ + Rendez sndr; /* process flow control */ + QLock sndrlock; + int sndfull; Reseq *reseq; /* Resequencing queue */ Timer timer; /* Activity timer */ diff --git a/port/tcpinput.c b/port/tcpinput.c index 9abfe04ab0e5bd43e77f16c7957a67f8ba13550a..8ccfa69af86ca86b932659cfb93b697a6a9b3036 100644 --- a/port/tcpinput.c +++ b/port/tcpinput.c @@ -559,6 +559,11 @@ update(Ipconv *s, Tcp *seg) tcb->flags &= ~RETRAN; tcb->backoff = 0; + + if(tcb->sndfull && tcb->sndcnt < Streamhi/2){ + wakeup(&tcb->sndr); + tcb->sndfull = 0; + } } int