shithub: riscv

Download patch

ref: b728f50a790afeec349c575b99028063a9d230c9
parent: 98dba9a4a311dd7b7435a5a5d66619f2a2b4b6cf
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Oct 23 13:16:22 EDT 2016

lib9p: limit the number of srv processes kept arround 8

--- a/sys/include/9p.h
+++ b/sys/include/9p.h
@@ -236,6 +236,8 @@
 	Ref	sref;	/* srvwork procs */
 	Ref	rref;	/* requests in flight */
 
+	int	spid;	/* pid of srv() caller */
+
 	void	(*free)(Srv*);
 };
 
--- a/sys/src/lib9p/srv.c
+++ b/sys/src/lib9p/srv.c
@@ -748,6 +748,11 @@
 		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 @@
 	fmtinstall('D', dirfmt);
 	fmtinstall('F', fcallfmt);
 
+	srv->spid = getpid();
 	srv->sref.ref = 0;
 	srv->rref.ref = 0;