summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rio
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-11-01 21:21:24 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2013-11-01 21:21:24 +0100
commitf37ee95fbcd5d837c4eff29e7feb5a999420dae2 (patch)
treed8d7fad4c6e551dac7eabcf4d7f97844ee6d883e /sys/src/cmd/rio
parent413977c19bb65fb1b704d58ae9a59cdf64179c84 (diff)
rio: enforce flush reply ordering for all xfids
flushing isnt optional for concurrently handled requests. we need to ensure that Rflush is replied *after* the origianl request. so we assign the flushtag for *every* xfid in xfidctl(), and filsysrespond() checks if the xfid was flushed *after* replying and wakes up the flushing xfid.
Diffstat (limited to 'sys/src/cmd/rio')
-rw-r--r--sys/src/cmd/rio/fsys.c2
-rw-r--r--sys/src/cmd/rio/xfid.c18
2 files changed, 9 insertions, 11 deletions
diff --git a/sys/src/cmd/rio/fsys.c b/sys/src/cmd/rio/fsys.c
index 5e680ea85..41db21b96 100644
--- a/sys/src/cmd/rio/fsys.c
+++ b/sys/src/cmd/rio/fsys.c
@@ -270,6 +270,8 @@ filsysrespond(Filsys *fs, Xfid *x, Fcall *t, char *err)
free(x->buf);
x->buf = nil;
x->flushtag = -1;
+ if(x->flushing)
+ recv(x->flushc, nil); /* wakeup flushing xfid */
return x;
}
diff --git a/sys/src/cmd/rio/xfid.c b/sys/src/cmd/rio/xfid.c
index 662d686cf..3e66de01d 100644
--- a/sys/src/cmd/rio/xfid.c
+++ b/sys/src/cmd/rio/xfid.c
@@ -80,6 +80,8 @@ xfidallocthread(void*)
fprint(2, "%p decref %ld\n", x, x->ref);
error("decref");
}
+ if(x->flushing)
+ error("flushing in free");
if(x->flushtag != -1)
error("flushtag in free");
x->free = xfidfree;
@@ -110,6 +112,7 @@ xfidctl(void *arg)
threadsetname(buf);
for(;;){
f = recvp(x->c);
+ x->flushtag = x->tag;
(*f)(x);
if(decref(x) == 0)
sendp(cxfidfree, x);
@@ -127,12 +130,13 @@ xfidflush(Xfid *x)
incref(xf); /* to hold data structures up at tail of synchronization */
if(xf->ref == 1)
error("ref 1 in flush");
- /* take over flushtag so follow up flushes wait for us */
- x->flushtag = x->oldtag;
xf->flushtag = -1;
break;
}
+ /* take over flushtag so follow up flushes wait for us */
+ x->flushtag = x->oldtag;
+
/*
* wakeup filsysflush() in the filsysproc so the next
* flush can come in.
@@ -257,7 +261,7 @@ xfidopen(Xfid *x)
w->ctlopen = TRUE;
break;
case Qkbdin:
- if(w != wkeyboard){
+ if(w != wkeyboard){
filsysrespond(x->fs, x, &t, Eperm);
return;
}
@@ -417,7 +421,6 @@ xfidwrite(Xfid *x)
memmove(x->f->rpart, x->data+nb, cnt-nb);
x->f->nrpart = cnt-nb;
}
- x->flushtag = x->tag;
alts[CWdata].c = w->conswrite;
alts[CWdata].v = &cwm;
@@ -658,8 +661,6 @@ xfidread(Xfid *x)
cnt = x->count;
switch(qid){
case Qcons:
- x->flushtag = x->tag;
-
alts[CRdata].c = w->consread;
alts[CRdata].v = &crm;
alts[CRdata].op = CHANRCV;
@@ -725,8 +726,6 @@ xfidread(Xfid *x)
break;
case Qmouse:
- x->flushtag = x->tag;
-
alts[MRdata].c = w->mouseread;
alts[MRdata].v = &mrm;
alts[MRdata].op = CHANRCV;
@@ -778,8 +777,6 @@ xfidread(Xfid *x)
break;
case Qkbd:
- x->flushtag = x->tag;
-
alts[MRdata].c = w->kbdread;
alts[MRdata].v = &krm;
alts[MRdata].op = CHANRCV;
@@ -919,7 +916,6 @@ xfidread(Xfid *x)
filsysrespond(x->fs, x, &fc, Etooshort);
break;
}
- x->flushtag = x->tag;
alts[WCRdata].c = w->wctlread;
alts[WCRdata].v = &cwrm;