Add status updates to a persistent list in the discover_server struct,
and send each client the backlog on connect. This avoids clients missing
useful messages from early init. Clients will only show this in the
backlog screen to avoid flooding the client's status line.
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
va_end(ap);
status.type = type;
va_end(ap);
status.type = type;
+ status.backlog = false;
pb_debug("boot status: [%d] %s\n", type, status.message);
pb_debug("boot status: [%d] %s\n", type, status.message);
status.type = type;
status.message = talloc_vasprintf(handler, fmt, ap);
status.type = type;
status.message = talloc_vasprintf(handler, fmt, ap);
+ status.backlog = false;
device_handler_status(handler, &status);
device_handler_status(handler, &status);
status.type = STATUS_INFO;
status.message = talloc_asprintf(handler,
_("Booting in %d sec: %s"), sec, opt->option->name);
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);
device_handler_status(handler, &status);
struct waitset *waitset;
struct waiter *waiter;
struct list clients;
struct waitset *waitset;
struct waiter *waiter;
struct list clients;
struct device_handler *device_handler;
};
struct device_handler *device_handler;
};
static int discover_server_process_connection(void *arg)
{
struct discover_server *server = arg;
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;
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);
+
void discover_server_notify_boot_status(struct discover_server *server,
struct status *status)
{
void discover_server_notify_boot_status(struct discover_server *server,
struct status *status)
{
+ struct statuslog_entry *entry;
+ /* 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);
}
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);
server->waiter = NULL;
server->waitset = waitset;
list_init(&server->clients);
+ list_init(&server->status);
int pb_protocol_boot_status_len(const struct status *status)
{
int pb_protocol_boot_status_len(const struct status *status)
{
4 + optional_strlen(status->message) +
4 + optional_strlen(status->message) +
pos += pb_protocol_serialise_string(pos, status->message);
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;
assert(pos <= buf + buf_len);
(void)buf_len;
if (read_string(status, &pos, &len, &status->message))
goto out;
if (read_string(status, &pos, &len, &status->message))
goto out;
+ /* backlog */
+ status->backlog = *(bool *)pos;
+ pos += sizeof(status->backlog);
+
STATUS_ERROR,
} type;
char *message;
STATUS_ERROR,
} type;
char *message;
+ bool backlog;
+};
+
+struct statuslog_entry {
+ struct status *status;
+ struct list_item list;
};
struct interface_info {
};
struct interface_info {
statuslog_append_steal(cui, cui->statuslog, status);
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 void cui_update_mm_title(struct cui *cui)
static const int max_status_entry = 10000;
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;
struct statuslog {
struct list status;
int n_status;