diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-08-05 04:21:34 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-08-05 04:21:34 +0200 |
commit | 684cf70857e78a209a794c6a699e7022c7c5ab0c (patch) | |
tree | 665db4ec5b248c7f69a2c07af60f434be2426485 /sys | |
parent | 1df707a0b2aaddb750fb707ae413dc67a19027a3 (diff) |
rio: make sure flush replies are send only *after* the request got flushed or was replied
due to the xfid handlers clearing flushtag too early, xfidflush might respond too early
causing spurious replies send later by the handler. now, we clear the flushtag in
filsysrespond *after* the reply was send. xfidflush will wait for us on the active
qlock.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/src/cmd/rio/fsys.c | 1 | ||||
-rw-r--r-- | sys/src/cmd/rio/xfid.c | 24 |
2 files changed, 13 insertions, 12 deletions
diff --git a/sys/src/cmd/rio/fsys.c b/sys/src/cmd/rio/fsys.c index fe4d186e4..f4fea7723 100644 --- a/sys/src/cmd/rio/fsys.c +++ b/sys/src/cmd/rio/fsys.c @@ -270,6 +270,7 @@ filsysrespond(Filsys *fs, Xfid *x, Fcall *t, char *err) fprint(2, "rio:->%F\n", t); free(x->buf); x->buf = nil; + x->flushtag = -1; return x; } diff --git a/sys/src/cmd/rio/xfid.c b/sys/src/cmd/rio/xfid.c index a0da0c5fd..c5067d524 100644 --- a/sys/src/cmd/rio/xfid.c +++ b/sys/src/cmd/rio/xfid.c @@ -416,8 +416,9 @@ xfidwrite(Xfid *x) } /* received data */ - x->flushtag = -1; + qlock(&x->active); if(x->flushing){ + qunlock(&x->active); recv(x->flushc, nil); /* wake up flushing xfid */ pair.s = runemalloc(1); pair.ns = 0; @@ -425,7 +426,6 @@ xfidwrite(Xfid *x) filsyscancel(x); return; } - qlock(&x->active); pair.s = r; pair.ns = nr; send(cwm.cw, &pair); @@ -641,27 +641,27 @@ xfidread(Xfid *x) } /* received data */ - x->flushtag = -1; c1 = crm.c1; c2 = crm.c2; t = malloc(cnt+UTFmax+1); /* room to unpack partial rune plus */ pair.s = t; pair.ns = cnt; send(c1, &pair); + qlock(&x->active); if(x->flushing){ + qunlock(&x->active); recv(x->flushc, nil); /* wake up flushing xfid */ recv(c2, nil); /* wake up window and toss data */ free(t); filsyscancel(x); return; } - qlock(&x->active); recv(c2, &pair); fc.data = pair.s; fc.count = pair.ns; filsysrespond(x->fs, x, &fc, nil); - free(t); qunlock(&x->active); + free(t); break; case Qlabel: @@ -695,14 +695,14 @@ xfidread(Xfid *x) } /* received data */ - x->flushtag = -1; + qlock(&x->active); if(x->flushing){ + qunlock(&x->active); recv(x->flushc, nil); /* wake up flushing xfid */ recv(mrm.cm, nil); /* wake up window and toss data */ filsyscancel(x); return; } - qlock(&x->active); recv(mrm.cm, &ms); c = 'm'; if(w->resized) @@ -736,14 +736,14 @@ xfidread(Xfid *x) /* received data */ t = recvp(krm.ck); - x->flushtag = -1; + qlock(&x->active); if(x->flushing){ + qunlock(&x->active); free(t); /* wake up window and toss data */ recv(x->flushc, nil); /* wake up flushing xfid */ filsyscancel(x); return; } - qlock(&x->active); fc.data = t; fc.count = strlen(t)+1; filsysrespond(x->fs, x, &fc, nil); @@ -863,29 +863,29 @@ xfidread(Xfid *x) } /* received data */ - x->flushtag = -1; c1 = cwrm.c1; c2 = cwrm.c2; t = malloc(cnt+1); /* be sure to have room for NUL */ pair.s = t; pair.ns = cnt+1; send(c1, &pair); + qlock(&x->active); if(x->flushing){ + qunlock(&x->active); recv(x->flushc, nil); /* wake up flushing xfid */ recv(c2, nil); /* wake up window and toss data */ free(t); filsyscancel(x); return; } - qlock(&x->active); recv(c2, &pair); fc.data = pair.s; if(pair.ns > cnt) pair.ns = cnt; fc.count = pair.ns; filsysrespond(x->fs, x, &fc, nil); - free(t); qunlock(&x->active); + free(t); break; default: |