From f2df868ea8f5bf58dfd8c5776b770098e69ee0f9 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 2 Mar 1990 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1990-03-02 --- port/devlance.c | 2 +- port/proc.c | 2 +- port/stream.c | 17 ++++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/port/devlance.c b/port/devlance.c index d1518fc524a49d57c609ddfaa49025f967dea5c9..0c8abf3d2b05650bcb0f0f5c2222890209512cc8 100644 --- a/port/devlance.c +++ b/port/devlance.c @@ -750,7 +750,7 @@ lancekproc(void *arg) * See if a queue exists for this packet type. */ p = l.rp[l.rl]; - t = (p->type[1]<<8) | p->type[0]; + t = (p->type[0]<<8) | p->type[1]; len = m->cntflags - 4; lancedebq("in", p, len); for(e = &l.e[0]; e < &l.e[Ntypes]; e++){ diff --git a/port/proc.c b/port/proc.c index e0d156021d781a2112931cff66e3b383c76f9db0..ff93da21165e52071fa2bb91210543f8336d4473 100644 --- a/port/proc.c +++ b/port/proc.c @@ -231,7 +231,7 @@ sleep1(Rendez *r, int (*f)(void*), void *arg) */ p = u->p; if(r->p) - print("double sleep %d\n", r->p->pid); + print("double sleep %d %d\n", r->p->pid, p->pid); p->r = r; p->wokeup = 0; p->state = Wakeme; diff --git a/port/stream.c b/port/stream.c index 2494f3914366efe2d58b2e7d73b2a9e35e2da170..2478fdc6ff255e8b1a15830b245a378a60366de8 100644 --- a/port/stream.c +++ b/port/stream.c @@ -571,6 +571,7 @@ streamclose(Chan *c) { Queue *q, *nq; Block *bp; + Stream *s = c->stream; /* * if not open, ignore it @@ -581,8 +582,9 @@ streamclose(Chan *c) /* * decrement the reference cound */ - lock(c->stream); - if(--(c->stream->inuse) != 0){ + lock(s); + if(s->inuse != 1){ + s->inuse--; unlock(c->stream); return; } @@ -590,21 +592,22 @@ streamclose(Chan *c) /* * descend the stream closing the queues */ - for(q = c->stream->procq; q; q = q->next){ + for(q = s->procq; q; q = q->next){ if(q->info->close) (*q->info->close)(q->other); - if(q == c->stream->devq->other) + if(q == s->devq->other) break; } /* * ascend the stream freeing the queues */ - for(q = c->stream->devq; q; q = nq){ + for(q = s->devq; q; q = nq){ nq = q->next; freeq(q); } - c->stream->id = c->stream->dev = c->stream->type = 0; - unlock(c->stream); + s->id = s->dev = s->type = 0; + s->inuse--; + unlock(s); } /*