shithub: riscv

Download patch

ref: 336df4d4aed17394d5a5fc8ae1f1c24df4c1cf5e
parent: d6e505167c3ea27e276319a0ee2387aa9b2be6b5
author: cinap_lenrek <[email protected]>
date: Thu Sep 13 23:35:15 EDT 2012

Qcoalesce patch to satisfy full read length

--- a/sys/src/9/omap/devuart.c
+++ b/sys/src/9/omap/devuart.c
@@ -47,7 +47,7 @@
 //		return nil;
 
 	if(p->iq == nil){
-		if((p->iq = qopen(8*1024, 0, uartflow, p)) == nil)
+		if((p->iq = qopen(8*1024, Qcoalesce, uartflow, p)) == nil)
 			return nil;
 	}
 	else
--- a/sys/src/9/pc/devkbd.c
+++ b/sys/src/9/pc/devkbd.c
@@ -432,7 +432,7 @@
 void
 kbdenable(void)
 {
-	kbd.q = qopen(4*1024, 0, 0, 0);
+	kbd.q = qopen(1024, Qcoalesce, 0, 0);
 	if(kbd.q == nil)
 		panic("kbdenable");
 	qnoblock(kbd.q, 1);
--- a/sys/src/9/pc/psaux.c
+++ b/sys/src/9/pc/psaux.c
@@ -48,7 +48,7 @@
 void
 psauxlink(void)
 {
-	psauxq = qopen(1024, 0, 0, 0);
+	psauxq = qopen(1024, Qcoalesce, 0, 0);
 	if(psauxq == nil)
 		panic("psauxlink");
 	qnoblock(psauxq, 1);
--- a/sys/src/9/port/devuart.c
+++ b/sys/src/9/port/devuart.c
@@ -44,7 +44,7 @@
 	if(p->enabled)
 		return p;
 	if(p->iq == nil){
-		if((p->iq = qopen(8*1024, 0, uartflow, p)) == nil)
+		if((p->iq = qopen(8*1024, Qcoalesce, uartflow, p)) == nil)
 			return nil;
 	}
 	else
--- a/sys/src/9/port/qio.c
+++ b/sys/src/9/port/qio.c
@@ -1097,29 +1097,25 @@
 	if(q->state & Qcoalesce){
 		/* when coalescing, 0 length blocks just go away */
 		b = q->bfirst;
-		if(BLEN(b) <= 0){
+		m = BLEN(b);
+		if(m <= 0){
 			freeb(qremove(q));
 			goto again;
 		}
 
 		/*  grab the first block plus as many
-		 *  following blocks as will completely
+		 *  following blocks as will partially
 		 *  fit in the read.
 		 */
 		n = 0;
 		l = &first;
-		m = BLEN(b);
 		for(;;) {
 			*l = qremove(q);
 			l = &b->next;
 			n += m;
-
-			b = q->bfirst;
-			if(b == nil)
+			if(n >= len || (b = q->bfirst) == nil)
 				break;
 			m = BLEN(b);
-			if(n+m > len)
-				break;
 		}
 	} else {
 		first = qremove(q);