]> git.lizzy.rs Git - plan9front.git/commitdiff
rio: make sure flush replies are send only *after* the request got flushed or was...
authorcinap_lenrek <cinap_lenrek@gmx.de>
Mon, 5 Aug 2013 02:21:34 +0000 (04:21 +0200)
committercinap_lenrek <cinap_lenrek@gmx.de>
Mon, 5 Aug 2013 02:21:34 +0000 (04:21 +0200)
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.

sys/src/cmd/rio/fsys.c
sys/src/cmd/rio/xfid.c

index fe4d186e48cb911b93836265ecb89c729663f7ce..f4fea77233ef913c04c9331d29a9e397d849952f 100644 (file)
@@ -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;
 }
 
index a0da0c5fdf3b217b926b43bae6dda27ebf885cb7..c5067d5248f02733f1c0ab8f1c473c58e6b67818 100644 (file)
@@ -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: