shithub: riscv

Download patch

ref: 5b07f6238bcc14a044d7fa4373eda9ce68d05d64
parent: e992808e49beb230edd9ae892244aac86ec34351
author: cinap_lenrek <cinap_lenrek@rei2>
date: Mon Feb 20 05:49:14 EST 2012

devdraw: use QLock to serialize sleep on refresh to prevent double sleep

--- a/sys/src/9/port/devdraw.c
+++ b/sys/src/9/port/devdraw.c
@@ -73,6 +73,7 @@
 	CScreen*	cscreen;
 	Refresh*	refresh;
 	Rendez		refrend;
+	QLock		refq;
 	uchar*		readdata;
 	int		nreaddata;
 	int		busy;
@@ -1227,10 +1228,17 @@
 				break;
 			dunlock();
 			if(waserror()){
-				dlock();	/* restore lock for waserror() above */
+				dlock();
 				nexterror();
 			}
+			eqlock(&cl->refq);
+			if(waserror()){
+				qunlock(&cl->refq);
+				nexterror();
+			}
 			sleep(&cl->refrend, drawrefactive, cl);
+			poperror();
+			qunlock(&cl->refq);
 			poperror();
 			dlock();
 		}