~kris/9p

9hist

6f8b2f54a9ac9802e94e8846cd87e08eb67ad37d — David du Colombier 31 years ago bb3383a
Plan 9 from Bell Labs 1995-07-13
1 files changed, 24 insertions(+), 3 deletions(-)

M pc/devether.c
M pc/devether.c => pc/devether.c +24 -3
@@ 103,15 103,36 @@ etherwstat(Chan *c, char *dp)
void
etherrloop(Ether *ctlr, Etherpkt *pkt, long len, int tome)
{
	Block *bp;
	ushort type;
	int i;
	Netfile *f, **fp, **ep;

	type = (pkt->type[0]<<8)|pkt->type[1];
	ep = &ctlr->f[Ntypes];
	for(fp = ctlr->f; fp < ep; fp++){
		if((f = *fp) && ((tome && f->type==type) || f->type < 0))
			if(qproduce(f->in, pkt->d, len) < 0)
				ctlr->soverflows++;
		if((f = *fp) && ((tome && f->type==type) || f->type < 0)){
			if(f->type > -2){
				if(qproduce(f->in, pkt->d, len) < 0)
					ctlr->soverflows++;
			} else {
				if(qwindow(f->in) <= 0)
					continue;
				if(len > 60)
					len = 60;
				bp = iallocb(len);
				if(bp == 0)
					continue;
				memmove(bp->wp, pkt->d, len);
				i = TK2MS(m->ticks);
				bp->wp[60] = i>>24;
				bp->wp[61] = i>>16;
				bp->wp[62] = i>>8;
				bp->wp[63] = i;
				bp->wp += 64;
				qpass(f->in, bp);
			}
		}
	}
}