va_end(ap);
status.type = type;
+ status.backlog = false;
pb_debug("boot status: [%d] %s\n", type, status.message);
status.type = type;
status.message = talloc_vasprintf(handler, fmt, ap);
+ status.backlog = false;
device_handler_status(handler, &status);
status.type = STATUS_INFO;
status.message = talloc_asprintf(handler,
_("Booting in %d sec: %s"), sec, opt->option->name);
+ status.backlog = false;
device_handler_status(handler, &status);
struct waitset *waitset;
struct waiter *waiter;
struct list clients;
+ struct list status;
struct device_handler *device_handler;
};
static int discover_server_process_connection(void *arg)
{
struct discover_server *server = arg;
+ struct statuslog_entry *entry;
int fd, rc, i, n_devices;
struct client *client;
}
}
+ /* send status backlog to client */
+ list_for_each_entry(&server->status, entry, list)
+ write_boot_status_message(server, client, entry->status);
+
return 0;
}
void discover_server_notify_boot_status(struct discover_server *server,
struct status *status)
{
+ struct statuslog_entry *entry;
struct client *client;
+ /* Duplicate the status struct to add to the backlog */
+ entry = talloc(server, struct statuslog_entry);
+ if (!entry) {
+ pb_log("Failed to allocated saved status!\n");
+ } else {
+ entry->status = talloc(entry, struct status);
+ if (entry->status) {
+ entry->status->type = status->type;
+ entry->status->message = talloc_strdup(entry->status,
+ status->message);
+ entry->status->backlog = true;
+ list_add_tail(&server->status, &entry->list);
+ } else {
+ talloc_free(entry);
+ }
+ }
+
list_for_each_entry(&server->clients, client, list)
write_boot_status_message(server, client, status);
}
server->waiter = NULL;
server->waitset = waitset;
list_init(&server->clients);
+ list_init(&server->status);
unlink(PB_SOCKET_PATH);
int pb_protocol_boot_status_len(const struct status *status)
{
- return 4 +
+ return 4 + /* type */
4 + optional_strlen(status->message) +
+ 4 + /* backlog */
4;
}
pos += pb_protocol_serialise_string(pos, status->message);
+ *(bool *)pos = __cpu_to_be32(status->backlog);
+ pos += sizeof(bool);
+
assert(pos <= buf + buf_len);
(void)buf_len;
if (read_string(status, &pos, &len, &status->message))
goto out;
+ /* backlog */
+ status->backlog = *(bool *)pos;
+ pos += sizeof(status->backlog);
+
rc = 0;
out:
STATUS_ERROR,
} type;
char *message;
+ bool backlog;
+};
+
+struct statuslog_entry {
+ struct status *status;
+ struct list_item list;
};
struct interface_info {
statuslog_append_steal(cui, cui->statuslog, status);
- nc_scr_status_printf(cui->current, "%s", status->message);
+ /* Ignore status messages from the backlog */
+ if (!status->backlog)
+ nc_scr_status_printf(cui->current, "%s", status->message);
}
static void cui_update_mm_title(struct cui *cui)
static const int max_status_entry = 10000;
-struct statuslog_entry {
- struct status *status;
- struct list_item list;
-};
-
struct statuslog {
struct list status;
int n_status;