From add111cd3f842f79573dd50d3afb26d1ae34ea2b Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 14 Apr 1997 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1997-04-14 --- port/pgrp.c | 45 +++++++++++++++++++++++++-------------------- port/qlock.c | 1 - 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/port/pgrp.c b/port/pgrp.c index 1ef04ea817d5ab6dbc8cfaea88a1c6f11a997ca2..ac4f3c0b041bfef080a3bc21d8058c119b333042 100644 --- a/port/pgrp.c +++ b/port/pgrp.c @@ -72,22 +72,23 @@ closepgrp(Pgrp *p) { Mhead **h, **e, *f, *next; - if(decref(p) == 0){ - qlock(&p->debug); - p->pgrpid = -1; - - e = &p->mnthash[MNTHASH]; - for(h = p->mnthash; h < e; h++) { - for(f = *h; f; f = next) { - cclose(f->from); - mountfree(f->mount); - next = f->hash; - free(f); - } + if(decref(p) != 0) + return; + + qlock(&p->debug); + p->pgrpid = -1; + + e = &p->mnthash[MNTHASH]; + for(h = p->mnthash; h < e; h++) { + for(f = *h; f; f = next) { + cclose(f->from); + mountfree(f->mount); + next = f->hash; + free(f); } - qunlock(&p->debug); - free(p); } + qunlock(&p->debug); + free(p); } void @@ -187,13 +188,17 @@ closefgrp(Fgrp *f) int i; Chan *c; - if(decref(f) == 0) { - for(i = 0; i <= f->maxfd; i++) - if(c = f->fd[i]) - cclose(c); + if(f == 0) + return; - free(f); - } + if(decref(f) != 0) + return; + + for(i = 0; i <= f->maxfd; i++) + if(c = f->fd[i]) + cclose(c); + + free(f); } Mount* diff --git a/port/qlock.c b/port/qlock.c index bb1e1aaeca933b2f38c7467cc083e0d394695ba6..0c664f773c38ed740e9111ee221333c2384cc04d 100644 --- a/port/qlock.c +++ b/port/qlock.c @@ -4,7 +4,6 @@ #include "dat.h" #include "fns.h" - void qlock(QLock *q) {