server: Allow handlers to fail init
If a handler fails its init, we don't want to invoke its callbacks.
This change adds a flag to struct handlers, to indicate whether a
handler is active (ie, init() has returned success). Only active
handlers are used.
We also change the handler list output to indicate which are active.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/console-server.h b/console-server.h
index 1a9e813..2658e89 100644
--- a/console-server.h
+++ b/console-server.h
@@ -16,6 +16,7 @@
#include <poll.h>
#include <stdint.h>
+#include <stdbool.h>
struct console;
struct config;
@@ -34,6 +35,7 @@
int (*data_in)(struct handler *handler,
uint8_t *buf, size_t len);
void (*fini)(struct handler *handler);
+ bool active;
};
#define __handler_name(n) __handler_ ## n