lib9p: limit the number of srv processes kept arround 8

This commit is contained in:
cinap_lenrek 2016-10-23 17:16:22 +02:00
parent 98dba9a4a3
commit b728f50a79
2 changed files with 8 additions and 0 deletions

View file

@ -236,6 +236,8 @@ struct Srv {
Ref sref; /* srvwork procs */
Ref rref; /* requests in flight */
int spid; /* pid of srv() caller */
void (*free)(Srv*);
};

View file

@ -748,6 +748,11 @@ srvwork(void *v)
case Tstat: sstat(srv, r); break;
case Twstat: swstat(srv, r); break;
}
if(srv->sref.ref > 8 && srv->spid != getpid()){
decref(&srv->sref);
qunlock(&srv->slock);
return;
}
qunlock(&srv->slock);
}
@ -803,6 +808,7 @@ srv(Srv *srv)
fmtinstall('D', dirfmt);
fmtinstall('F', fcallfmt);
srv->spid = getpid();
srv->sref.ref = 0;
srv->rref.ref = 0;