- /* initialize out_port */
- statd_get_socket(out_port);
-
- for (;;) {
- if (!(run_mode & MODE_NOTIFY_ONLY)) {
- /* Do not do pmap_unset() when running in notify mode.
- * We may clear the portmapper record for a statd not
- * running in notify mode disabling it.
- * Juan C. Gomez j_carlos_gomez@yahoo.com
- */
- pmap_unset (SM_PROG, SM_VERS);
+ /* Make sure we have a privilege port for calling into the kernel */
+ if (statd_get_socket() < 0)
+ exit(1);
+
+ /* 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();
+
+ MY_STATE = nsm_get_state(0);
+ if (MY_STATE == 0)
+ exit(1);
+ xlog(D_GENERAL, "Local NSM state number: %d", MY_STATE);
+ nsm_update_kernel_state(MY_STATE);
+
+ 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;
+ if (write(pipefds[1], &status, 1) != 1) {
+ xlog_warn("writing to parent pipe failed: errno %d (%s)\n",
+ errno, strerror(errno));