git: 9front

Download patch

ref: 5bfb517c8495cc7ed22b04555d8066a880a82565
parent: 493201f71802df13d224f964fc528de234043c95
author: cinap_lenrek <cinap_lenrek@rei2>
date: Thu Jan 12 07:54:45 EST 2012

fix race condition of the CCACHE flag by clearing the flag in
attachimage() instead of temporarily reseting in pio().

--- a/sys/src/9/port/fault.c
+++ b/sys/src/9/port/fault.c
@@ -200,7 +200,7 @@
 	Page *new;
 	KMap *k;
 	Chan *c;
-	int n, ask, cache;
+	int n, ask;
 	char *kaddr;
 	ulong daddr;
 	Page *loadrec;
@@ -238,9 +238,7 @@
 	k = kmap(new);
 	kaddr = (char*)VA(k);
 
-	cache = c->flag & CCACHE;
 	while(waserror()) {
-		c->flag |= cache;
 		if(strcmp(up->errstr, Eintr) == 0)
 			continue;
 		kunmap(k);
@@ -247,9 +245,7 @@
 		putpage(new);
 		faulterror(Eioload, c, 0);
 	}
-	c->flag &= ~CCACHE;
 	n = devtab[c->type]->read(c, kaddr, ask, daddr);
-	c->flag |= cache;
 	if(n != ask)
 		faulterror(Eioload, c, 0);
 	if(ask < BY2PG)
--- a/sys/src/9/port/segment.c
+++ b/sys/src/9/port/segment.c
@@ -287,6 +287,7 @@
 
 	lock(i);
 	incref(c);
+	c->flag &= ~CCACHE;
 	i->c = c;
 	i->type = c->type;
 	i->qid = c->qid;
--