From 478fa39134a53d7276c893a1fab51bb1b73acbf6 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 23 Sep 1998 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1998-09-23 --- ip/il.c | 5 ++++- ip/tcp.c | 5 ++++- port/portdat.h | 2 +- port/proc.c | 1 + port/qio.c | 43 ++++++++++++------------------------------- port/sysfile.c | 2 +- 6 files changed, 23 insertions(+), 35 deletions(-) diff --git a/ip/il.c b/ip/il.c index 162156d555138757a5194899c3394cdf85db7c62..847329c9548764c64eafae58942831003258bcaf 100644 --- a/ip/il.c +++ b/ip/il.c @@ -884,7 +884,10 @@ ilpullup(Conv *s) bp = concatblock(bp); if(bp == 0) panic("ilpullup"); - qpassnolim(s->rq, packblock(bp)); + bp = packblock(bp); + if(bp == 0) + panic("ilpullup2"); + qpassnolim(s->rq, bp); } qunlock(&ic->outo); } diff --git a/ip/tcp.c b/ip/tcp.c index fbeee413247098dd4ab2f33f0166dc6076914ed1..b0cf5abf975eaa0163bd43f09baad14c25c6bf84 100644 --- a/ip/tcp.c +++ b/ip/tcp.c @@ -1384,7 +1384,10 @@ tcpiput(Proto *tcp, uchar*, Block *bp) * receive queue */ if(bp) { - qpassnolim(s->rq, packblock(bp)); + bp = packblock(bp); + if(bp == nil) + panic("tcp packblock"); + qpassnolim(s->rq, bp); bp = nil; } tcb->rcv.nxt += length; diff --git a/port/portdat.h b/port/portdat.h index a6ab45a7926ab2a850a501372ad44e8a84dc4ba1..bc56295b5f8ad21e0a06e863c26b964c8a5d21a2 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -136,7 +136,7 @@ struct Block ulong flag; }; #define BLEN(s) ((s)->wp - (s)->rp) -#define BALLOC(s) ((s)->lim - (s)->base); +#define BALLOC(s) ((s)->lim - (s)->base) struct Chan { diff --git a/port/proc.c b/port/proc.c index 033e7d36f42126f8e3c7923aebac8d336765ee89..5367e2a49547d7f18dee07c990229b2428c80cde 100644 --- a/port/proc.c +++ b/port/proc.c @@ -219,6 +219,7 @@ loop: p = rq->head; if(p != nil) p->movetime = 0; + goto found; } } else { /* diff --git a/port/qio.c b/port/qio.c index 390f7546ddcd84a0f953dc90cfa668c991f51704..43770a896addf3aec8b7dcd40934c94c2bb9ed07 100644 --- a/port/qio.c +++ b/port/qio.c @@ -95,19 +95,6 @@ checkb(Block *b, char *msg) } -void -checkqlen(Queue *q) -{ - int len; - Block *b; - - len = 0; - for(b = q->bfirst; b; b = b->next) - len += BALLOC(b); - if(len != q->len) - panic("checkqlen"); -} - void ixsummary(void) { @@ -693,7 +680,6 @@ qpass(Queue *q, Block *b) q->state &= ~Qstarve; dowakeup = 1; } -checkqlen(q); iunlock(q); if(dowakeup) @@ -736,7 +722,6 @@ qpassnolim(Queue *q, Block *b) q->state &= ~Qstarve; dowakeup = 1; } -checkqlen(q); iunlock(q); if(dowakeup) @@ -752,19 +737,19 @@ checkqlen(q); Block* packblock(Block *bp) { - int len, alen; - Block *nbp; - - len = alen = 0; - for(nbp = bp; nbp; nbp = bp->next){ - len += BLEN(bp); - alen += BALLOC(bp); - } + Block **l, *nbp; + int n; - if(alen >= (len<<2)){ - nbp = allocb(len); - nbp->next = bp; - return pullupblock(nbp, len); + for(l = &bp; *l; l = &(*l)->next){ + nbp = *l; + n = BLEN(nbp); + if((n<<2) < BALLOC(nbp)){ + *l = allocb(n); + memmove((*l)->wp, nbp->rp, n); + (*l)->wp += n; + (*l)->next = nbp->next; + freeb(nbp); + } } return bp; @@ -811,7 +796,6 @@ qproduce(Queue *q, void *vp, int len) q->state &= ~Qstarve; dowakeup = 1; } -checkqlen(q); iunlock(q); if(dowakeup) @@ -981,7 +965,6 @@ qbread(Queue *q, int len) nb->wp = nb->rp + len; } -checkqlen(q); iunlock(q); /* wakeup flow controlled writers */ @@ -1080,7 +1063,6 @@ qbwrite(Queue *q, Block *b) dowakeup = 1; } -checkqlen(q); iunlock(q); if(dowakeup){ @@ -1169,7 +1151,6 @@ qiwrite(Queue *q, void *vp, int len) dowakeup = 1; } -checkqlen(q); iunlock(q); if(dowakeup){ diff --git a/port/sysfile.c b/port/sysfile.c index 13cc5dd47cd8f7fd1f17b92d7fb163f8e4be0c74..14c239e8350961116f52041e4766441d7a85500b 100644 --- a/port/sysfile.c +++ b/port/sysfile.c @@ -470,7 +470,7 @@ syswrite(ulong *arg) if(m < n){ lock(c); - c->offset = oo + m; + c->offset -= n - m; unlock(c); }