shithub: riscv

Download patch

ref: b4d2e39d8cfad9fe9585dd6b2382d1261122f22f
parent: 15c0d4b7c42f973296f372330fefe1c7f08895b4
author: cinap_lenrek <[email protected]>
date: Sat Jul 28 15:17:54 EDT 2012

ndb/cs/dns: make sure never to block the 9p loop when we run out of processes, fail the request instead

--- a/sys/src/cmd/ndb/cs.c
+++ b/sys/src/cmd/ndb/cs.c
@@ -1654,6 +1654,10 @@
 
 	qunlock(&dblock);
 	slave(host);
+	if(*isslave == 0){
+		qlock(&dblock);
+		return nil;
+	}
 
 	if(strcmp(ipattr(host), "ip") == 0)
 		t = dnsquery(mntpt, host, "ptr");
--- a/sys/src/cmd/ndb/dnresolve.c
+++ b/sys/src/cmd/ndb/dnresolve.c
@@ -1603,11 +1603,15 @@
 		return Answnone;
 
 	slave(qp->req);
+
 	/*
 	 * slave might have forked.  if so, the parent process longjmped to
 	 * req->mret; we're usually the child slave, but if there are too
-	 * many children already, we're still the same process.
+	 * many children already, we're still the same process. under no
+	 * circumstances block the 9p loop.
 	 */
+	if(!qp->req->isslave && strcmp(qp->req->from, "9p") == 0)
+		return Answnone;
 
 	/*
 	 * don't lock before call to slave so only children can block.
@@ -1636,7 +1640,7 @@
 					" dropping this one; no further logging"
 					" of drops", dp->name);
 			}
-			return 0;
+			return Answnone;
 		}
 		++qlp->Ref.ref;
 		qunlock(qlp);