shithub: riscv

Download patch

ref: 577d31ab137f300e8b6fcb25bbb206777fb8d557
parent: 75e1ef0ab60acb6bccc54254b82770aec5786ead
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;