freebsd/libshare: nfs: don't send SIGHUP to all processes
pidfile_open() sets *pidptr to -1 if the process currently holding the lock is between pidfile_open() and pidfile_write(), the subsequent kill(mountdpid) would potentially SIGHUP all non-system processes except init: just sleep for half a millisecond and try again in that case Reviewed-by: Don Brady <don.brady@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: John Kennedy <john.kennedy@delphix.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12067
This commit is contained in:
parent
9ec630ff2c
commit
a1a52a356b
|
@ -423,9 +423,10 @@ nfs_commit_shares(void)
|
||||||
struct pidfh *pfh;
|
struct pidfh *pfh;
|
||||||
pid_t mountdpid;
|
pid_t mountdpid;
|
||||||
|
|
||||||
|
start:
|
||||||
pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &mountdpid);
|
pfh = pidfile_open(_PATH_MOUNTDPID, 0600, &mountdpid);
|
||||||
if (pfh != NULL) {
|
if (pfh != NULL) {
|
||||||
/* Mountd is not running. */
|
/* mountd(8) is not running. */
|
||||||
pidfile_remove(pfh);
|
pidfile_remove(pfh);
|
||||||
return (SA_OK);
|
return (SA_OK);
|
||||||
}
|
}
|
||||||
|
@ -433,6 +434,11 @@ nfs_commit_shares(void)
|
||||||
/* Cannot open pidfile for some reason. */
|
/* Cannot open pidfile for some reason. */
|
||||||
return (SA_SYSTEM_ERR);
|
return (SA_SYSTEM_ERR);
|
||||||
}
|
}
|
||||||
|
if (mountdpid == -1) {
|
||||||
|
/* mountd(8) exists, but didn't write the PID yet */
|
||||||
|
usleep(500);
|
||||||
|
goto start;
|
||||||
|
}
|
||||||
/* We have mountd(8) PID in mountdpid variable. */
|
/* We have mountd(8) PID in mountdpid variable. */
|
||||||
kill(mountdpid, SIGHUP);
|
kill(mountdpid, SIGHUP);
|
||||||
return (SA_OK);
|
return (SA_OK);
|
||||||
|
|
Loading…
Reference in New Issue