X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fstatd%2Fstatd.c;h=091ced9316e9220408fb7799004c297b8c0fd9ec;hb=63d92ed0bc0e62b77e974b10f4ec02f004ef33cc;hp=22d5deb51ecfb38afbb9650a3ae0149e0726998a;hpb=6b82a93f2dc7f303103540babb74a75e41b84008;p=nfs-utils.git diff --git a/utils/statd/statd.c b/utils/statd/statd.c index 22d5deb..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; @@ -476,25 +475,31 @@ int main (int argc, char **argv) waitpid(pid, NULL, 0); } + /* Make sure we have a privilege port for calling into the kernel */ + statd_get_socket(); - for (;;) { - pmap_unset (SM_PROG, SM_VERS); + /* If sm-notify didn't take all the state files, load + * state information into our notify-list so we can + * pass on any SM_NOTIFY that arrives + */ + load_state(); - /* 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; - } + pmap_unset (SM_PROG, SM_VERS); - /* 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 (once) { - once = 0; - drop_privs(); - } + /* 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; + } + + drop_privs(); + + for (;;) { /* * Handle incoming requests: SM_NOTIFY socket requests, as * well as callbacks from lockd.