diff options
author | Neil Brown <neilb@suse.de> | 2007-03-29 13:08:03 +1000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2007-03-29 13:08:03 +1000 |
commit | 25001e18ff31933d1f40b510da969a8cee317310 (patch) | |
tree | 2c2bff0ac8c73ac8e811b917b1aa0230a87ca32e /utils/statd/statd.c | |
parent | 849cdc25d0060621662b7b311e02bcabc92fb4d7 (diff) | |
download | nfs-utils-25001e18ff31933d1f40b510da969a8cee317310.tar.gz nfs-utils-25001e18ff31933d1f40b510da969a8cee317310.tar.xz nfs-utils-25001e18ff31933d1f40b510da969a8cee317310.zip |
statd - only unregister/register once.
The for loop that restarts on SIGUSR or simu_reboot currently includes
several once-only things, that are probably best taken out of the loop.
We also take the unregister/register out of the loop as if statd does
drop privileges, then the second register won't use a privileged port
properly.
On the whole, cleaner code.
Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'utils/statd/statd.c')
-rw-r--r-- | utils/statd/statd.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/utils/statd/statd.c b/utils/statd/statd.c index a44f39f..091ced9 100644 --- a/utils/statd/statd.c +++ b/utils/statd/statd.c @@ -249,7 +249,6 @@ int main (int argc, char **argv) int arg; int port = 0, out_port = 0; struct rlimit rlim; - int once = 1; int pipefds[2] = { -1, -1}; char status; @@ -485,24 +484,22 @@ int main (int argc, char **argv) */ load_state(); - for (;;) { - pmap_unset (SM_PROG, SM_VERS); + pmap_unset (SM_PROG, SM_VERS); - /* If we got this far, we have successfully started, so notify parent */ - if (pipefds[1] > 0) { - status = 0; - write(pipefds[1], &status, 1); - close(pipefds[1]); - pipefds[1] = -1; - } + /* this registers both UDP and TCP services */ + rpc_init("statd", SM_PROG, SM_VERS, sm_prog_1, port); - /* this registers both UDP and TCP services */ - rpc_init("statd", SM_PROG, SM_VERS, sm_prog_1, port); + /* If we got this far, we have successfully started, so notify parent */ + if (pipefds[1] > 0) { + status = 0; + write(pipefds[1], &status, 1); + close(pipefds[1]); + pipefds[1] = -1; + } - if (once) { - once = 0; - drop_privs(); - } + drop_privs(); + + for (;;) { /* * Handle incoming requests: SM_NOTIFY socket requests, as * well as callbacks from lockd. |