fix edit pipe bug
This commit is contained in:
parent
11b0772a33
commit
6630175602
3 changed files with 48 additions and 2 deletions
|
|
@ -269,6 +269,7 @@ struct Window
|
||||||
int tagexpand;
|
int tagexpand;
|
||||||
int taglines;
|
int taglines;
|
||||||
Rectangle tagtop;
|
Rectangle tagtop;
|
||||||
|
QLock editoutlk;
|
||||||
};
|
};
|
||||||
|
|
||||||
void wininit(Window*, Window*, Rectangle);
|
void wininit(Window*, Window*, Rectangle);
|
||||||
|
|
@ -562,4 +563,6 @@ Channel *cerr; /* chan(char*) */
|
||||||
Channel *cedit; /* chan(int) */
|
Channel *cedit; /* chan(int) */
|
||||||
Channel *cwarn; /* chan(void*)[1] (really chan(unit)[1]) */
|
Channel *cwarn; /* chan(void*)[1] (really chan(unit)[1]) */
|
||||||
|
|
||||||
|
QLock editoutlk;
|
||||||
|
|
||||||
#define STACK 32768
|
#define STACK 32768
|
||||||
|
|
|
||||||
|
|
@ -592,6 +592,7 @@ runpipe(Text *t, int cmd, Rune *cr, int ncr, int state)
|
||||||
int n;
|
int n;
|
||||||
Runestr dir;
|
Runestr dir;
|
||||||
Window *w;
|
Window *w;
|
||||||
|
QLock *q;
|
||||||
|
|
||||||
r = skipbl(cr, ncr, &n);
|
r = skipbl(cr, ncr, &n);
|
||||||
if(n == 0)
|
if(n == 0)
|
||||||
|
|
@ -626,6 +627,23 @@ runpipe(Text *t, int cmd, Rune *cr, int ncr, int state)
|
||||||
winunlock(t->w);
|
winunlock(t->w);
|
||||||
qunlock(&row.lk);
|
qunlock(&row.lk);
|
||||||
recvul(cedit);
|
recvul(cedit);
|
||||||
|
/*
|
||||||
|
* The editoutlk exists only so that we can tell when
|
||||||
|
* the editout file has been closed. It can get closed *after*
|
||||||
|
* the process exits because, since the process cannot be
|
||||||
|
* connected directly to editout (no 9P kernel support),
|
||||||
|
* the process is actually connected to a pipe to another
|
||||||
|
* process (arranged via 9pserve) that reads from the pipe
|
||||||
|
* and then writes the data in the pipe to editout using
|
||||||
|
* 9P transactions. This process might still have a couple
|
||||||
|
* writes left to copy after the original process has exited.
|
||||||
|
*/
|
||||||
|
if(w)
|
||||||
|
q = &w->editoutlk;
|
||||||
|
else
|
||||||
|
q = &editoutlk;
|
||||||
|
qlock(q); /* wait for file to close */
|
||||||
|
qunlock(q);
|
||||||
qlock(&row.lk);
|
qlock(&row.lk);
|
||||||
editing = Inactive;
|
editing = Inactive;
|
||||||
if(t!=nil && t->w!=nil)
|
if(t!=nil && t->w!=nil)
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,9 @@ xfidopen(Xfid *x)
|
||||||
|
|
||||||
w = x->f->w;
|
w = x->f->w;
|
||||||
t = &w->body;
|
t = &w->body;
|
||||||
|
q = FILE(x->f->qid);
|
||||||
if(w){
|
if(w){
|
||||||
winlock(w, 'E');
|
winlock(w, 'E');
|
||||||
q = FILE(x->f->qid);
|
|
||||||
switch(q){
|
switch(q){
|
||||||
case QWaddr:
|
case QWaddr:
|
||||||
if(w->nopen[q]++ == 0){
|
if(w->nopen[q]++ == 0){
|
||||||
|
|
@ -174,11 +174,26 @@ xfidopen(Xfid *x)
|
||||||
respond(x, &fc, Eperm);
|
respond(x, &fc, Eperm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!canqlock(&w->editoutlk)){
|
||||||
|
winunlock(w);
|
||||||
|
respond(x, &fc, Einuse);
|
||||||
|
return;
|
||||||
|
}
|
||||||
w->wrselrange = range(t->q1, t->q1);
|
w->wrselrange = range(t->q1, t->q1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
winunlock(w);
|
winunlock(w);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
switch(q){
|
||||||
|
case Qeditout:
|
||||||
|
if(!canqlock(&editoutlk)){
|
||||||
|
respond(x, &fc, Einuse);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
fc.qid = x->f->qid;
|
fc.qid = x->f->qid;
|
||||||
fc.iounit = messagesize-IOHDRSZ;
|
fc.iounit = messagesize-IOHDRSZ;
|
||||||
x->f->open = TRUE;
|
x->f->open = TRUE;
|
||||||
|
|
@ -203,10 +218,10 @@ xfidclose(Xfid *x)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
q = FILE(x->f->qid);
|
||||||
x->f->open = FALSE;
|
x->f->open = FALSE;
|
||||||
if(w){
|
if(w){
|
||||||
winlock(w, 'E');
|
winlock(w, 'E');
|
||||||
q = FILE(x->f->qid);
|
|
||||||
switch(q){
|
switch(q){
|
||||||
case QWctl:
|
case QWctl:
|
||||||
if(w->ctlfid!=~0 && w->ctlfid==x->f->fid){
|
if(w->ctlfid!=~0 && w->ctlfid==x->f->fid){
|
||||||
|
|
@ -247,10 +262,20 @@ xfidclose(Xfid *x)
|
||||||
min(w->wrselrange.q1, t->file->b.nc), 1);
|
min(w->wrselrange.q1, t->file->b.nc), 1);
|
||||||
textscrdraw(t);
|
textscrdraw(t);
|
||||||
break;
|
break;
|
||||||
|
case QWeditout:
|
||||||
|
qunlock(&w->editoutlk);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
winunlock(w);
|
winunlock(w);
|
||||||
winclose(w);
|
winclose(w);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
switch(q){
|
||||||
|
case Qeditout:
|
||||||
|
qunlock(&editoutlk);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
respond(x, &fc, nil);
|
respond(x, &fc, nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue