summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rio/fsys.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-11-01 18:57:11 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2013-11-01 18:57:11 +0100
commit413977c19bb65fb1b704d58ae9a59cdf64179c84 (patch)
tree43159f5a41cb1ed5cda9ac9ab93bd60d2ec49364 /sys/src/cmd/rio/fsys.c
parentf87baec1d0369764b761e8ca26a910e982123453 (diff)
rio: properly handle follow up flushes (fixes unexpected reply tag)
when multiple flushes are send, they need to be replied in order. we ensure this by having the flush xfid taking over the flushtag (synchronized with a new fs->csyncflush channel) so the next flush will flush the previous flush.
Diffstat (limited to 'sys/src/cmd/rio/fsys.c')
-rw-r--r--sys/src/cmd/rio/fsys.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/sys/src/cmd/rio/fsys.c b/sys/src/cmd/rio/fsys.c
index f4fea7723..5e680ea85 100644
--- a/sys/src/cmd/rio/fsys.c
+++ b/sys/src/cmd/rio/fsys.c
@@ -18,10 +18,6 @@ char Eoffset[] = "illegal offset";
int messagesize = 8192+IOHDRSZ; /* good start */
-enum{
- DEBUG = 0
-};
-
Dirtab dirtab[]=
{
{ ".", QTDIR, Qdir, 0500|DMDIR },
@@ -142,6 +138,9 @@ filsysinit(Channel *cxfidalloc)
close(fd);
}
fs->user = estrdup(buf);
+ fs->csyncflush = chancreate(sizeof(int), 0);
+ if(fs->csyncflush == nil)
+ error("chancreate syncflush");
fs->cxfidalloc = cxfidalloc;
pid = getpid();
@@ -210,7 +209,7 @@ filsysproc(void *arg)
x->buf = buf;
if(convM2S(buf, n, x) != n)
error("convert error in convM2S");
- if(DEBUG)
+ if(debug)
fprint(2, "rio:<-%F\n", &x->Fcall);
if(fcall[x->type] == nil)
x = filsysrespond(fs, x, &t, Ebadfcall);
@@ -266,7 +265,7 @@ filsysrespond(Filsys *fs, Xfid *x, Fcall *t, char *err)
error("convert error in convS2M");
if(write(fs->sfd, x->buf, n) != n)
error("write error in respond");
- if(DEBUG)
+ if(debug)
fprint(2, "rio:->%F\n", t);
free(x->buf);
x->buf = nil;
@@ -307,14 +306,21 @@ filsysauth(Filsys *fs, Xfid *x, Fid*)
{
Fcall t;
- return filsysrespond(fs, x, &t, "rio: authentication not required");
+ return filsysrespond(fs, x, &t, "rio: authentication not required");
}
static
Xfid*
-filsysflush(Filsys*, Xfid *x, Fid*)
+filsysflush(Filsys *fs, Xfid *x, Fid*)
{
sendp(x->c, xfidflush);
+
+ /*
+ * flushes need to be replied in order. xfidflush() will
+ * awaken us when the flush has been queued.
+ */
+ recv(fs->csyncflush, nil);
+
return nil;
}