diff options
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/9pserve.c | 67 | ||||
-rw-r--r-- | src/cmd/acme/fsys.c | 7 | ||||
-rw-r--r-- | src/cmd/acme/mkfile | 2 | ||||
-rw-r--r-- | src/cmd/acme/xfid.c | 1 | ||||
-rw-r--r-- | src/cmd/mkfile | 2 |
5 files changed, 52 insertions, 27 deletions
diff --git a/src/cmd/9pserve.c b/src/cmd/9pserve.c index c33beb14..eb2df758 100644 --- a/src/cmd/9pserve.c +++ b/src/cmd/9pserve.c @@ -352,8 +352,8 @@ connthread(void *arg) m->afid->ref++; break; case Topenfd: - if(m->tx.mode != OREAD && (m->tx.mode&~OTRUNC) != OWRITE){ - err(m, "openfd mode must be OREAD or OWRITE"); + if(m->tx.mode&~(OTRUNC|3)){ + err(m, "bad openfd mode"); continue; } m->isopenfd = 1; @@ -489,13 +489,17 @@ openfdthread(void *v) m->ref++; sendomsg(m); recvp(c->internal); - if(m->rx.type == Rerror) + if(m->rx.type == Rerror){ + // fprint(2, "read error: %s\n", m->rx.ename); break; + } if(m->rx.count == 0) break; tot += m->rx.count; - if(iowrite(io, c->fd, m->rx.data, m->rx.count) != m->rx.count) + if(iowrite(io, c->fd, m->rx.data, m->rx.count) != m->rx.count){ + fprint(2, "pipe write error: %r\n"); break; + } msgput(m); msgput(m); } @@ -503,6 +507,8 @@ openfdthread(void *v) for(;;){ if(verbose) fprint(2, "twrite..."); if((n=ioread(io, c->fd, buf, sizeof buf)) <= 0){ + if(n < 0) + fprint(2, "pipe read error: %r\n"); m = nil; break; } @@ -520,8 +526,10 @@ openfdthread(void *v) m->ref++; sendomsg(m); recvp(c->internal); - if(m->rx.type == Rerror) - break; + if(m->rx.type == Rerror){ + // fprint(2, "write error: %s\n", m->rx.ename); + continue; + } tot = n; msgput(m); msgput(m); @@ -534,18 +542,20 @@ openfdthread(void *v) msgput(m); msgput(m); } - m = msgnew(); - m->internal = 1; - m->c = c; - m->tx.type = Tclunk; - m->tx.fid = fid->fid; - m->fid = fid; - fid->ref++; - m->ref++; - sendomsg(m); - recvp(c->internal); - msgput(m); - msgput(m); + if(fid->ref == 1){ + m = msgnew(); + m->internal = 1; + m->c = c; + m->tx.type = Tclunk; + m->tx.fid = fid->fid; + m->fid = fid; + fid->ref++; + m->ref++; + sendomsg(m); + recvp(c->internal); + msgput(m); + msgput(m); + } fidput(fid); c->fdfid = nil; chanfree(c->internal); @@ -578,13 +588,24 @@ xopenfd(Msg *m) nc->fdmode = m->tx.mode; nc->fd = p[0]; - /* clunk fid from other connection */ - if(delhash(m->c->fid, m->fid->cfid, m->fid) == 0) - fidput(m->fid); - /* a thread to tend the pipe */ threadcreate(openfdthread, nc, STACK); + /* if mode is ORDWR, that openfdthread will write; start a reader */ + if((m->tx.mode&3) == ORDWR){ + nc = emalloc(sizeof(Conn)); + nc->internal = chancreate(sizeof(void*), 0); + nc->fdfid = m->fid; + m->fid->ref++; + nc->fdmode = OREAD; + nc->fd = dup(p[0], -1); + threadcreate(openfdthread, nc, STACK); + } + + /* steal fid from other connection */ + if(delhash(m->c->fid, m->fid->cfid, m->fid) == 0) + fidput(m->fid); + /* rewrite as Ropenfd */ m->rx.type = Ropenfd; n = GBIT32(m->rpkt); @@ -1265,7 +1286,7 @@ iowrite(Ioproc *io, int fd, void *v, long n) u = v; for(tot=0; tot<n; tot+=m){ m = _iowrite(io, fd, u+tot, n-tot); - if(m <= 0){ + if(m < 0){ if(tot) break; return m; diff --git a/src/cmd/acme/fsys.c b/src/cmd/acme/fsys.c index cd333dc7..d220bdef 100644 --- a/src/cmd/acme/fsys.c +++ b/src/cmd/acme/fsys.c @@ -306,6 +306,7 @@ fsysattach(Xfid *x, Fid *f) Fcall t; int id; Mntdir *m; + char buf[128]; if(strcmp(x->fcall.uname, user) != 0) return respond(x, &t, Eperm); @@ -327,8 +328,10 @@ fsysattach(Xfid *x, Fid *f) m->ref++; break; } - if(m == nil) - sendp(cerr, estrdup("unknown id in attach")); + if(m == nil){ + snprint(buf, sizeof buf, "unknown id '%s' in attach", x->fcall.aname); + sendp(cerr, estrdup(buf)); + } qunlock(&mnt.lk); return respond(x, &t, nil); } diff --git a/src/cmd/acme/mkfile b/src/cmd/acme/mkfile index 84149eb9..f92f903a 100644 --- a/src/cmd/acme/mkfile +++ b/src/cmd/acme/mkfile @@ -36,6 +36,6 @@ UPDATE=\ <$PLAN9/src/mkone -LDFLAGS=$LDFLAGS -lfs -lmux -lplumb -lthread -lframe -ldraw -lbio -l9 -lfmt -lutf -L$X11/lib -lX11 +LDFLAGS=$LDFLAGS -lplumb -lfs -lmux -lthread -lframe -ldraw -lbio -l9 -lfmt -lutf -L$X11/lib -lX11 edit.$O ecmd.$O elog.$O: edit.h diff --git a/src/cmd/acme/xfid.c b/src/cmd/acme/xfid.c index f397623e..13af7395 100644 --- a/src/cmd/acme/xfid.c +++ b/src/cmd/acme/xfid.c @@ -194,6 +194,7 @@ xfidclose(Xfid *x) w = x->f->w; x->f->busy = FALSE; + x->f->w = nil; if(x->f->open == FALSE){ if(w != nil) winclose(w); diff --git a/src/cmd/mkfile b/src/cmd/mkfile index e2131e77..f6365ac0 100644 --- a/src/cmd/mkfile +++ b/src/cmd/mkfile @@ -6,7 +6,7 @@ LDFLAGS=$LDFLAGS -lthread -lsec -lfs -lmux -lregexp9 -lbio -l9 -lfmt -lutf <$PLAN9/src/mkmany -BUGGERED='CVS|oplumb|plumb2|mk|vac|9term|venti|htmlfmt' +BUGGERED='CVS|faces|factotum|oplumb|plumb2|mk|vac|9term|upas|venti|htmlfmt' DIRS=`ls -l |sed -n 's/^d.* //p' |egrep -v "$BUGGERED"` <$PLAN9/src/mkdirs |