From 316bcac02cbca3811c36812f877d4682bf9b4440 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 20 Oct 1990 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1990-10-20 --- gnot/devdk.c | 54 +++++++++++++++++++++++++++++++++++++++++------ power/devhotrod.c | 3 ++- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/gnot/devdk.c b/gnot/devdk.c index 3220ae9877af76205e3e34ab81fdddc2cf18a7d4..93dd488ef23f71280235a7cebd669c820388527f 100644 --- a/gnot/devdk.c +++ b/gnot/devdk.c @@ -206,6 +206,7 @@ static void dkmuxopen(Queue *q, Stream *s) { Dk *dp; + Line *lp; int i; for(dp = dk; dp < &dk[Ndk]; dp++){ @@ -222,6 +223,9 @@ dkmuxopen(Queue *q, Stream *s) dp->lines = 16; dp->name[0] = 0; dp->wq = WR(q); + for(lp = dp->line; lp < &dp->line[Nline]; lp++) + if(lp->state != 0) + panic("dkmuxopen l %d s %lux", lp-dp->line, lp->state); qunlock(dp); return; } @@ -1368,15 +1372,15 @@ dkchgmesg(Dk *dp, Dkmsg *dialp, int line) { Line *lp; - if (line <= 0 || line >= dp->lines) { - /* tell controller this line is not in use */ - dkmesg(dp, T_CHG, D_CLOSE, line, 0); - return; - } - lp = &dp->line[line]; switch (dialp->srv) { case D_CLOSE: /* remote shutdown */ + if (line <= 0 || line >= dp->lines) { + /* tell controller this line is not in use */ + dkmesg(dp, T_CHG, D_CLOSE, line, 0); + return; + } + lp = &dp->line[line]; switch (lp->state) { case Ldialing: @@ -1407,6 +1411,12 @@ dkchgmesg(Dk *dp, Dkmsg *dialp, int line) break; case D_ISCLOSED: /* acknowledging a local shutdown */ + if (line <= 0 || line >= dp->lines) { + /* tell controller this line is not in use */ + dkmesg(dp, T_CHG, D_CLOSE, line, 0); + return; + } + lp = &dp->line[line]; switch (lp->state) { case Llclose: case Lclosed: @@ -1421,6 +1431,36 @@ dkchgmesg(Dk *dp, Dkmsg *dialp, int line) } break; + case D_CLOSEALL: + for(line = dp->ncsc+1; line < dp->lines; line++){ + lp = &dp->line[line]; + switch (lp->state) { + + case Ldialing: + /* simulate a failed connection */ + dkreplymesg(dp, (Dkmsg *)0, line); + lp->state = Lrclose; + break; + + case Lrclose: + case Lconnected: + case Llistening: + case Lackwait: + dkhangup(lp); + lp->state = Lrclose; + break; + + case Lopened: + break; + + case Llclose: + case Lclosed: + lp->state = Lclosed; + break; + } + } + break; + default: print("unrecognized T_CHG\n"); } @@ -1503,7 +1543,7 @@ dktimer(void *a) * remind controller of dead lines and * timeout calls that take to long */ - for (i=0; ilines; i++){ + for (i=dp->ncsc+1; ilines; i++){ lp = &dp->line[i]; switch(lp->state){ case Llclose: diff --git a/power/devhotrod.c b/power/devhotrod.c index 007d2b6cd8b28300b2795f02b3fdc808fe33ccbb..b90036b9d45d62878b7134a2846221823a2be7ee 100644 --- a/power/devhotrod.c +++ b/power/devhotrod.c @@ -169,8 +169,9 @@ hotrodread(Chan *c, void *buf, long n) to = buf; from = &dp->mem[c->offset/sizeof(ulong)]; end = to + (n/sizeof(ulong)); - while(to != end) + while(to != end){ *to++ = *from++; + } qunlock(hp); return n; }