summaryrefslogtreecommitdiff
path: root/sys/src/9/port/devproc.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-08-27 23:57:17 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-08-27 23:57:17 +0200
commit43d3c87294b34d1a79d3789518eee75f2ead246b (patch)
treeea45c3714371286c796c2da5a62c63da8553766f /sys/src/9/port/devproc.c
parent84109a3159249369d1869fd887a7040b766e4540 (diff)
devproc: properly handle exclusive refcount for /proc/trace
Diffstat (limited to 'sys/src/9/port/devproc.c')
-rw-r--r--sys/src/9/port/devproc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/src/9/port/devproc.c b/sys/src/9/port/devproc.c
index 4b47b3035..663a0205d 100644
--- a/sys/src/9/port/devproc.c
+++ b/sys/src/9/port/devproc.c
@@ -351,12 +351,12 @@ procopen(Chan *c, int omode)
error(Eperm);
lock(&tlock);
if (waserror()){
+ topens--;
unlock(&tlock);
nexterror();
}
- if (topens > 0)
+ if (topens++ > 0)
error("already open");
- topens++;
if (tevents == nil){
tevents = (Traceevent*)malloc(sizeof(Traceevent) * Nevents);
if(tevents == nil)
@@ -613,9 +613,9 @@ procfds(Proc *p, char *va, int count, long offset)
}
static void
-procclose(Chan * c)
+procclose(Chan *c)
{
- if(QID(c->qid) == Qtrace){
+ if(QID(c->qid) == Qtrace && (c->flag & COPEN) != 0){
lock(&tlock);
if(topens > 0)
topens--;
@@ -623,8 +623,10 @@ procclose(Chan * c)
proctrace = nil;
unlock(&tlock);
}
- if(QID(c->qid) == Qns && c->aux != 0)
+ if(QID(c->qid) == Qns && c->aux != 0){
free(c->aux);
+ c->aux = 0;
+ }
}
static void