summaryrefslogtreecommitdiffstats
path: root/lib/pb-protocol/pb-protocol.c
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-12-14 14:44:23 +1100
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-12-20 16:40:22 +1100
commit75c97cfd449b2bac8e61af1017a83bdf43f5e8fe (patch)
treecc6b4a0bf23e58cb1cd737a3cefdf7c54c4f7566 /lib/pb-protocol/pb-protocol.c
parent6a065198be213092c67071ee77eccf3e493a4cba (diff)
downloadpetitboot-75c97cfd449b2bac8e61af1017a83bdf43f5e8fe.zip
petitboot-75c97cfd449b2bac8e61af1017a83bdf43f5e8fe.tar.gz
discover: Maintain a backlog of status updates
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>
Diffstat (limited to 'lib/pb-protocol/pb-protocol.c')
-rw-r--r--lib/pb-protocol/pb-protocol.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index 8bc8820..65a1e93 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -217,8 +217,9 @@ int pb_protocol_boot_len(const struct boot_command *boot)
int pb_protocol_boot_status_len(const struct status *status)
{
- return 4 +
+ return 4 + /* type */
4 + optional_strlen(status->message) +
+ 4 + /* backlog */
4;
}
@@ -410,6 +411,9 @@ int pb_protocol_serialise_boot_status(const struct status *status,
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;
@@ -847,6 +851,10 @@ int pb_protocol_deserialise_boot_status(struct status *status,
if (read_string(status, &pos, &len, &status->message))
goto out;
+ /* backlog */
+ status->backlog = *(bool *)pos;
+ pos += sizeof(status->backlog);
+
rc = 0;
out:
OpenPOWER on IntegriCloud