Commits

jsgf committed c85a7aa

Maybe fix Bos's insanity spin

  • Participants
  • Parent commits 86f1ef8

Comments (0)

Files changed (4)

docs/state-machine.dot

 
   insane -> probing [label="regained\nsanity"];
 
-  probing -> down [label="probe done"];
+  probing -> down [label="probe\ndone"];
   probing -> probing_up [label="up -> 1"];
 
   down -> inactive [label="up -> 1"];
 
-  probing_up -> inactive [label="probe done"];
+  probing_up -> inactive [label="probe\ndone"];
+  probing_up -> probing [label="up -> 0"];
 
   inactive -> inning [label="running -> 1"];
 
                 /* already down */
                 break;
 
+	    case ST_PROBING:
+		/* already probing - don't do anything rash */
+		break;
+
+	    case ST_PROBING_UP:
+		/* well, we were up, but now we're not */
+		info->state = ST_PROBING;
+		break;
+
             default:
                 /* All other states: kill off any scripts currently
                    running, and go into the PROBING state, attempting
 static void
 usage(char *progname, int exitcode)
 {
-    fprintf(stderr, "Usage: %s [-FPcip]\n", progname);
+    fprintf(stderr, "Usage: %s [-DFP] [-c config-file] [-i interface] [-p pid-file]\n", 
+	    progname);
 
+    fprintf(stderr, "\t-D\t\t"
+            "print extra debugging messages\n");
     fprintf(stderr, "\t-F\t\t"
             "run in foreground (don't become a daemon)\n");
     fprintf(stderr, "\t-P\t\t"
 
         /* Make sure we don't miss anything interesting */
         poll_interfaces();
-
-        ret = poll(fds, sizeof(fds)/sizeof(fds[0]), -1);
-
-        if (ret == -1) {
-            if (errno == EINTR)
-                continue;
-            do_log(LOG_ERR, "poll failed: %m");
-            exit(1);
-        }
-        if (ret == 0)
-            continue;           /* XXX??? */
-
-        if (fds[0].revents & POLLIN) {
-            /* interface flag state change */
-            if (netlink_listen(fd, handle_interface, NULL) == 0)
-                break;          /* done */
-        }
-
-        if (fds[1].revents & POLLIN) {
-            /* netplug script finished */
-            int ret;
-            struct child_exit ce;
-
-            do {
-                ret = read(child_handler_pipe[0], &ce, sizeof(ce));
-
-                assert(ret == 0 || ret == -1 || ret == sizeof(ce));
-
-                if (ret == sizeof(ce))
-                    ifsm_scriptdone(ce.pid, ce.status);
-                else if (ret == -1 && errno != EAGAIN) {
-                    do_log(LOG_ERR, "pipe read failed: %m");
-                    exit(1);
-                }
-            } while(ret == sizeof(ce));
-        }
     }
 
     return 0;

man/man8/netplugd.8

 .It Fl i Ar interface_pattern
 Specify a pattern that will be used to match interface names that
 .Nm
-should manage.  You can probide this option multiple times to specify
+should manage.  You can provide this option multiple times to specify
 multiple patterns.
 .\"
 .It Fl p Ar pid_file
 .Bl -tag -width Ds
 .It in
 A cable was plugged in, or carrier came up.  The command should bring
-the interface up.  The command is run asynchronously, and its exit
-status is ignored.
+the interface up.  The command is run asynchronously, and it should
+exit with status 0 on success.
 .It out
 A cable was plugged out, or carrier went down.  The command should
-bring the interface down.  The command is run asynchronously, and its exit
-status is ignored.
+bring the interface down.  The command is run asynchronously, and it should
+exit with status 0 on success.
 .It probe
 The command should load and initialise the driver for this interface,
 if possible, and bring the interface into the "up" state, so that it