From fd5a7168b3dbb13e2c2aa75373bb26dcb7fd7bc4 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 2 May 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-05-02 --- port/devmnt.c | 8 +++++++- port/devnonet.c | 24 +++++++++++++++++++++--- port/portdat.h | 1 + port/stream.c | 26 +++++++++++++++++++++++++- 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/port/devmnt.c b/port/devmnt.c index 091ab782b795e2c16e13ba4c9f0721cde01c6a93..1b31d703a7f0835e3bb0f7a7fd57c13ba15de4f1 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -784,9 +784,12 @@ mntxmit(Mnt *m, Mnthdr *mh) nexterror(); } mh->mbr = mballoc(); - n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE, 0); + do{ + n = (*devtab[q->msg->type].read)(q->msg, mh->mbr->buf, BUFSIZE, 0); + }while(n == 0); poperror(); /* 3 */ if(convM2S(mh->mbr->buf, &mh->rhdr, n) == 0){ +print("POO bad len %d %ux!\n", n, mh->mbr->buf[0]); mnterrdequeue(m, mh); error(Ebadmsg); } @@ -868,6 +871,9 @@ mntxmit(Mnt *m, Mnthdr *mh) error(Eshutdown); }else if(mh->rhdr.type != mh->thdr.type+1){ print("bad type %d not %d in mntxmit\n", mh->rhdr.type, mh->thdr.type+1); +/*XXX*/ print("chan %c %d %lux %lux\n", devchar[m->q->msg->type], + m->q->msg->dev, m->q->msg->qid.path, + m->q->msg->stream); error(Ebadmsg); } /* diff --git a/port/devnonet.c b/port/devnonet.c index 51538ad551635034d090628eec4ddfec2abc26c3..4acb51329df4dec7f40de544c3263d07a2330d7c 100644 --- a/port/devnonet.c +++ b/port/devnonet.c @@ -540,6 +540,10 @@ noiput(Queue *q, Block *bp) /* * queue a block */ +enum { + Window= 1, +}; + static int windowopen(void *a) { @@ -548,9 +552,9 @@ windowopen(void *a) cp = (Noconv *)a; i = cp->next - cp->first; - if(i>=0 && i<32) + if(i>=0 && irptr + offset; @@ -1390,7 +1395,20 @@ nonetcksum(Block *bp, int offset) s = (s&0xffff) + (s>>16); hp->sum[1] = s>>8; hp->sum[0] = s; - return s & 0xffff; + s &= 0xffff; + switch(s){ + case 0xac9f: + case 0xc1a4: + case 0xc41c: + case 0xc46d: + { int i; + print("%lux s,", s); + for(bp = first; bp; bp = bp->next) + for(i = 0; i < BLEN(bp); i++) + print(" %ux", bp->rptr[i]); + } + } + return s; } /* diff --git a/port/portdat.h b/port/portdat.h index 8de6acea57b55cc8b8bfc9376e46175fb18d7f73..444f4c0cc5d98f173d3004013760e4a12e0bc6b7 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -409,6 +409,7 @@ struct Stream { Queue *procq; /* write queue at process end */ Queue *devq; /* read queue at device end */ Block *err; /* error message from down stream */ + int forcedelim; /* force a delimiter before the next message */ }; /* diff --git a/port/stream.c b/port/stream.c index 211098ec5122ac7190489a6887e74bc02be1b7df..82e8bab858525b9783ef083801fdaff1220805d7 100644 --- a/port/stream.c +++ b/port/stream.c @@ -1010,6 +1010,9 @@ stputq(Queue *q, Block *bp) wakeup(q->other->rp); delim = 1; } else { + if(BLEN(bp) == 1 && *(bp->rptr) == 1) + print("stputq u->p->pid %d %s\n", u->p->pid, u->p->text); + lock(q); if(q->first) q->last->next = bp; @@ -1268,6 +1271,9 @@ streamwrite(Chan *c, void *a, long n, int docopy) s = c->stream; + if(n == 1 && *((char*)a) == 1) + print("u->p->pid %d %s\n", u->p->pid, u->p->text); + /* * decode the qid */ @@ -1285,7 +1291,24 @@ streamwrite(Chan *c, void *a, long n, int docopy) error(Ehungup); } - if(!docopy && isphys(a)){ + /* + * if an error occurs during write n, + * force a delim before write n+1 + */ + if(waserror()){ + s->forcedelim = 1; + nexterror(); + } + if(s->forcedelim){ + FLOWCTL(q); + bp = allocb(0); + bp->flags |= S_DELIM; + bp->type = M_DATA; + PUTNEXT(q, bp); + s->forcedelim = 0; + } + + if(0 && !docopy && isphys(a)){ /* * `a' is global to the whole system, just create a * pointer to it and pass it on. @@ -1322,6 +1345,7 @@ streamwrite(Chan *c, void *a, long n, int docopy) } } } + poperror(); return n; }