diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-03-07 20:19:14 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-03-07 20:19:14 +0100 |
commit | 225c359beab9e2f17c66e65647b9e0a94f942620 (patch) | |
tree | f68865f87f1c741a3a7205d66a1f9a0cddc7bde2 /sys | |
parent | e1cdcfdb172071bafef18b1ac160138c97459b79 (diff) |
lib9p: get rid of Srv.nopipe and Srv.leavefdsopen hacks
it is unclear how Srv.nopipe flag should work inside
postmountserv(). if a server wants to serve on stdio
descriptors, he can just call srv() after initializing
Srv.infd and Srv.outfd.
The Srv.leavefdsopen hack can be removed now that acme
win has been fixed.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/include/9p.h | 2 | ||||
-rw-r--r-- | sys/man/2/9p | 6 | ||||
-rw-r--r-- | sys/src/lib9p/post.c | 86 | ||||
-rw-r--r-- | sys/src/lib9p/ramfs.c | 2 |
4 files changed, 23 insertions, 73 deletions
diff --git a/sys/include/9p.h b/sys/include/9p.h index c51b1c2b9..53b16ca4a 100644 --- a/sys/include/9p.h +++ b/sys/include/9p.h @@ -215,9 +215,7 @@ struct Srv { int infd; int outfd; - int nopipe; int srvfd; - int leavefdsopen; /* magic for acme win */ char* keyspec; /* below is implementation-specific; don't use */ diff --git a/sys/man/2/9p b/sys/man/2/9p index f0f50a87e..c1c75fd61 100644 --- a/sys/man/2/9p +++ b/sys/man/2/9p @@ -59,7 +59,6 @@ typedef struct Srv { int infd; int outfd; int srvfd; - int nopipe; } Srv; .fi .PP @@ -175,10 +174,7 @@ are wrappers that create a separate process in which to run .IR srv . They do the following: .IP -If -.IB s -> nopipe -is zero (the common case), -initialize +Initialize .IB s -> infd and .IB s -> outfd diff --git a/sys/src/lib9p/post.c b/sys/src/lib9p/post.c index 8abddfbd1..0241c3157 100644 --- a/sys/src/lib9p/post.c +++ b/sys/src/lib9p/post.c @@ -12,42 +12,22 @@ _postmountsrv(Srv *s, char *name, char *mtpt, int flag) { int fd[2]; - if(!s->nopipe){ - if(pipe(fd) < 0) - sysfatal("pipe: %r"); - s->infd = s->outfd = fd[1]; - s->srvfd = fd[0]; - } + if(pipe(fd) < 0) + sysfatal("pipe: %r"); + s->infd = s->outfd = fd[1]; + s->srvfd = fd[0]; + if(name) if(postfd(name, s->srvfd) < 0) sysfatal("postfd %s: %r", name); if(_forker == nil) sysfatal("no forker"); - _forker(postproc, s, RFNAMEG); - - /* - * Normally the server is posting as the last thing it does - * before exiting, so the correct thing to do is drop into - * a different fd space and close the 9P server half of the - * pipe before trying to mount the kernel half. This way, - * if the file server dies, we don't have a ref to the 9P server - * half of the pipe. Then killing the other procs will drop - * all the refs on the 9P server half, and the mount will fail. - * Otherwise the mount hangs forever. - * - * Libthread in general and acme win in particular make - * it hard to make this fd bookkeeping work out properly, - * so leaveinfdopen is a flag that win sets to opt out of this - * safety net. - */ - if(!s->leavefdsopen){ - rfork(RFFDG); - rendezvous(0, 0); - close(s->infd); - if(s->infd != s->outfd) - close(s->outfd); - } + _forker(postproc, s, RFNAMEG|RFFDG|RFNOTEG); + + close(s->infd); + if(s->infd != s->outfd) + close(s->outfd); if(mtpt){ if(amount(s->srvfd, mtpt, flag, "") == -1) @@ -61,42 +41,22 @@ _postsharesrv(Srv *s, char *name, char *mtpt, char *desc) { int fd[2]; - if(!s->nopipe){ - if(pipe(fd) < 0) - sysfatal("pipe: %r"); - s->infd = s->outfd = fd[1]; - s->srvfd = fd[0]; - } + if(pipe(fd) < 0) + sysfatal("pipe: %r"); + s->infd = s->outfd = fd[1]; + s->srvfd = fd[0]; + if(name) if(postfd(name, s->srvfd) < 0) sysfatal("postfd %s: %r", name); if(_forker == nil) sysfatal("no forker"); - _forker(postproc, s, RFNAMEG); - - /* - * Normally the server is posting as the last thing it does - * before exiting, so the correct thing to do is drop into - * a different fd space and close the 9P server half of the - * pipe before trying to mount the kernel half. This way, - * if the file server dies, we don't have a ref to the 9P server - * half of the pipe. Then killing the other procs will drop - * all the refs on the 9P server half, and the mount will fail. - * Otherwise the mount hangs forever. - * - * Libthread in general and acme win in particular make - * it hard to make this fd bookkeeping work out properly, - * so leaveinfdopen is a flag that win sets to opt out of this - * safety net. - */ - if(!s->leavefdsopen){ - rfork(RFFDG); - rendezvous(0, 0); - close(s->infd); - if(s->infd != s->outfd) - close(s->outfd); - } + _forker(postproc, s, RFNAMEG|RFFDG|RFNOTEG); + + close(s->infd); + if(s->infd != s->outfd) + close(s->outfd); if(mtpt){ if(sharefd(mtpt, desc, s->srvfd) < 0) @@ -112,10 +72,6 @@ postproc(void *v) Srv *s; s = v; - if(!s->leavefdsopen){ - rfork(RFNOTEG); - rendezvous(0, 0); - close(s->srvfd); - } + close(s->srvfd); srv(s); } diff --git a/sys/src/lib9p/ramfs.c b/sys/src/lib9p/ramfs.c index 13004a4ec..10e9b98be 100644 --- a/sys/src/lib9p/ramfs.c +++ b/sys/src/lib9p/ramfs.c @@ -158,7 +158,7 @@ main(int argc, char **argv) usage(); if(chatty9p) - fprint(2, "ramsrv.nopipe %d srvname %s mtpt %s\n", fs.nopipe, srvname, mtpt); + fprint(2, "srvname %s mtpt %s\n", srvname, mtpt); if(addr == nil && srvname == nil && mtpt == nil) sysfatal("must specify -a, -s, or -m option"); if(addr) |