fix race condition of the CCACHE flag by clearing the flag in

attachimage() instead of temporarily reseting in pio().
front
cinap_lenrek 2012-01-12 12:54:45 +01:00
parent 75e1ef0ab6
commit 577d31ab13
2 changed files with 2 additions and 5 deletions

View File

@ -200,7 +200,7 @@ pio(Segment *s, ulong addr, ulong soff, Page **p)
Page *new;
KMap *k;
Chan *c;
int n, ask, cache;
int n, ask;
char *kaddr;
ulong daddr;
Page *loadrec;
@ -238,18 +238,14 @@ retry:
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);
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)

View File

@ -287,6 +287,7 @@ attachimage(int type, Chan *c, ulong base, ulong len)
lock(i);
incref(c);
c->flag &= ~CCACHE;
i->c = c;
i->type = c->type;
i->qid = c->qid;