devproc: properly handle exclusive refcount for /proc/trace
This commit is contained in:
parent
84109a3159
commit
43d3c87294
1 changed files with 7 additions and 5 deletions
|
@ -351,12 +351,12 @@ procopen(Chan *c, int omode)
|
||||||
error(Eperm);
|
error(Eperm);
|
||||||
lock(&tlock);
|
lock(&tlock);
|
||||||
if (waserror()){
|
if (waserror()){
|
||||||
|
topens--;
|
||||||
unlock(&tlock);
|
unlock(&tlock);
|
||||||
nexterror();
|
nexterror();
|
||||||
}
|
}
|
||||||
if (topens > 0)
|
if (topens++ > 0)
|
||||||
error("already open");
|
error("already open");
|
||||||
topens++;
|
|
||||||
if (tevents == nil){
|
if (tevents == nil){
|
||||||
tevents = (Traceevent*)malloc(sizeof(Traceevent) * Nevents);
|
tevents = (Traceevent*)malloc(sizeof(Traceevent) * Nevents);
|
||||||
if(tevents == nil)
|
if(tevents == nil)
|
||||||
|
@ -613,9 +613,9 @@ procfds(Proc *p, char *va, int count, long offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
procclose(Chan * c)
|
procclose(Chan *c)
|
||||||
{
|
{
|
||||||
if(QID(c->qid) == Qtrace){
|
if(QID(c->qid) == Qtrace && (c->flag & COPEN) != 0){
|
||||||
lock(&tlock);
|
lock(&tlock);
|
||||||
if(topens > 0)
|
if(topens > 0)
|
||||||
topens--;
|
topens--;
|
||||||
|
@ -623,8 +623,10 @@ procclose(Chan * c)
|
||||||
proctrace = nil;
|
proctrace = nil;
|
||||||
unlock(&tlock);
|
unlock(&tlock);
|
||||||
}
|
}
|
||||||
if(QID(c->qid) == Qns && c->aux != 0)
|
if(QID(c->qid) == Qns && c->aux != 0){
|
||||||
free(c->aux);
|
free(c->aux);
|
||||||
|
c->aux = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue