]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/statd/statd.c
statd - only unregister/register once.
[nfs-utils.git] / utils / statd / statd.c
index 17e2947b35f0b8021fb2b170e854dbe8156c92a4..091ced9316e9220408fb7799004c297b8c0fd9ec 100644 (file)
@@ -230,12 +230,10 @@ static void run_sm_notify(int outport)
                av[ac++] = op;
        }
        if (run_mode & STATIC_HOSTNAME) {
-               av[ac++] = "-N";
+               av[ac++] = "-v";
                av[ac++] = MY_NAME;
        }
        av[ac] = NULL;
-       fprintf(stderr, "%s: -N deprecated, consider using /usr/sbin/sm-notify directly\n",
-               name_p);
        execv(av[0], av);
        fprintf(stderr, "%s: failed to run %s\n", name_p, av[0]);
        exit(2);
@@ -368,8 +366,11 @@ int main (int argc, char **argv)
                exit(-1);
        }
 
-       if (run_mode & MODE_NOTIFY_ONLY)
+       if (run_mode & MODE_NOTIFY_ONLY) {
+               fprintf(stderr, "%s: -N deprecated, consider using /usr/sbin/sm-notify directly\n",
+                       name_p);
                run_sm_notify(out_port);
+       }
 
 
        if (!(run_mode & MODE_NODAEMON)) {
@@ -474,22 +475,31 @@ int main (int argc, char **argv)
                        waitpid(pid, NULL, 0);
                }
 
-       drop_privs();
+       /* 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);
+
+       /* 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);
+       drop_privs();
 
+       for (;;) {
                /*
                 * Handle incoming requests:  SM_NOTIFY socket requests, as
                 * well as callbacks from lockd.