added shutdown forwarding to clients

This commit is contained in:
Dominik Maier 2021-03-11 02:12:01 +01:00
parent c44113e54d
commit 84a5627bed
2 changed files with 12 additions and 1 deletions

View File

@ -101,6 +101,9 @@ use crate::{
use super::shmem::HasFd;
/// The sender on this map is exiting (if broker exits, clients should exit gracefully);
const LLMP_TAG_EXITING: u32 = 0x13C5171;
/// We'll start off with 256 megabyte maps per fuzzer client
const LLMP_PREF_INITIAL_MAP_SIZE: usize = 1 << 28;
/// What byte count to align messages to
@ -987,6 +990,11 @@ where
// Handle special, LLMP internal, messages.
match (*msg).tag {
LLMP_TAG_UNSET => panic!("BUG: Read unallocated msg"),
LLMP_TAG_EXITING => {
// The other side is done.
assert_eq!((*msg).buf_len, 0);
return Err(Error::ShuttingDown);
}
LLMP_TAG_END_OF_PAGE => {
#[cfg(feature = "std")]
dbg!("Got end of page, allocing next");
@ -1389,6 +1397,9 @@ where
None => (),
}
}
self.llmp_out
.send_buf(LLMP_TAG_EXITING, &[])
.expect("Error when shutting down broker: Could not send LLMP_TAG_EXITING msg.");
}
/// Broadcasts the given buf to all lients

View File

@ -352,7 +352,7 @@ where
llmp::LlmpConnection::IsClient { client } => {
while let Some((sender_id, tag, msg)) = client.recv_buf()? {
if tag == _LLMP_TAG_EVENT_TO_BROKER {
continue;
panic!("EVENT_TO_BROKER parcel should not have arrived in the client!");
}
let event: Event<I> = postcard::from_bytes(msg)?;
events.push((sender_id, event));