shithub: riscv

Download patch

ref: 89625510554e65ec088110195670092bfe95fea4
parent: dbf13129a702cc066517acf147fb01c13df456cb
author: cinap_lenrek <[email protected]>
date: Sun Apr 22 14:50:11 EDT 2018

devip: increment in counter *AFTER* acquiering the ifc lock or loopbackmedium

--- a/sys/src/9/ip/loopbackmedium.c
+++ b/sys/src/9/ip/loopbackmedium.c
@@ -75,7 +75,7 @@
 	lb = ifc->arg;
 	lb->readp = up;	/* hide identity under a rock for unbind */
 	if(waserror()){
-		lb->readp = 0;
+		lb->readp = nil;
 		pexit("hangup", 1);
 	}
 	for(;;){
@@ -82,7 +82,6 @@
 		bp = qbread(lb->q, Maxtu);
 		if(bp == nil)
 			continue;
-		ifc->in++;
 		if(!canrlock(ifc)){
 			freeb(bp);
 			continue;
@@ -91,6 +90,7 @@
 			runlock(ifc);
 			nexterror();
 		}
+		ifc->in++;
 		if(ifc->lifc == nil)
 			freeb(bp);
 		else
--- a/sys/src/9/ip/netdevmedium.c
+++ b/sys/src/9/ip/netdevmedium.c
@@ -117,7 +117,6 @@
 			/*
 			 * get here if mchan is a pipe and other side hangs up
 			 * clean up this interface & get out
-ZZZ is this a good idea?
 			 */
 			poperror();
 			er->readp = nil;