M ip/il.c => ip/il.c +4 -1
@@ 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);
}
M ip/tcp.c => ip/tcp.c +4 -1
@@ 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;
M port/portdat.h => port/portdat.h +1 -1
@@ 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
{
M port/proc.c => port/proc.c +1 -0
@@ 219,6 219,7 @@ loop:
p = rq->head;
if(p != nil)
p->movetime = 0;
+ goto found;
}
} else {
/*
M port/qio.c => port/qio.c +12 -31
@@ 96,19 96,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)
{
debugging ^= 1;
@@ 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){
M port/sysfile.c => port/sysfile.c +1 -1
@@ 470,7 470,7 @@ syswrite(ulong *arg)
if(m < n){
lock(c);
- c->offset = oo + m;
+ c->offset -= n - m;
unlock(c);
}