vacfs: fix create srv with ORCLOSE on plan 9
In the current code, the srv file is removed just after the main thread exits, while the srv thread is still running, which is not the expected behavior. We moved the srv creation just before the procrfork, in order that the srv file will not be removed until the srv thread exits. R=rsc http://codereview.appspot.com/6397047
This commit is contained in:
parent
ac2662695a
commit
3a616eaa80
1 changed files with 11 additions and 9 deletions
|
|
@ -233,6 +233,17 @@ threadmain(int argc, char *argv[])
|
||||||
mfd[0] = p[0];
|
mfd[0] = p[0];
|
||||||
mfd[1] = p[0];
|
mfd[1] = p[0];
|
||||||
srvfd = p[1];
|
srvfd = p[1];
|
||||||
|
#ifndef PLAN9PORT
|
||||||
|
if(defsrv){
|
||||||
|
srvname = smprint("/srv/%s", defsrv);
|
||||||
|
fd = create(srvname, OWRITE|ORCLOSE, 0666);
|
||||||
|
if(fd < 0)
|
||||||
|
sysfatal("create %s: %r", srvname);
|
||||||
|
if(fprint(fd, "%d", srvfd) < 0)
|
||||||
|
sysfatal("write %s: %r", srvname);
|
||||||
|
free(srvname);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PLAN9PORT
|
#ifdef PLAN9PORT
|
||||||
|
|
@ -245,15 +256,6 @@ threadmain(int argc, char *argv[])
|
||||||
|
|
||||||
if(!stdio){
|
if(!stdio){
|
||||||
close(p[0]);
|
close(p[0]);
|
||||||
if(defsrv){
|
|
||||||
srvname = smprint("/srv/%s", defsrv);
|
|
||||||
fd = create(srvname, OWRITE|ORCLOSE, 0666);
|
|
||||||
if(fd < 0)
|
|
||||||
sysfatal("create %s: %r", srvname);
|
|
||||||
if(fprint(fd, "%d", srvfd) < 0)
|
|
||||||
sysfatal("write %s: %r", srvname);
|
|
||||||
free(srvname);
|
|
||||||
}
|
|
||||||
if(defmnt){
|
if(defmnt){
|
||||||
if(mount(srvfd, -1, defmnt, MREPL|MCREATE, "") < 0)
|
if(mount(srvfd, -1, defmnt, MREPL|MCREATE, "") < 0)
|
||||||
sysfatal("mount %s: %r", defmnt);
|
sysfatal("mount %s: %r", defmnt);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue