Skip to content

Commit bcec0a6

Browse files
committed
Shove the whole socket into the workspace
1 parent b869258 commit bcec0a6

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

humility-hiffy/src/lib.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,8 @@ impl<'a> HiffyContext<'a> {
480480
hubris: Option<std::ptr::NonNull<HubrisArchive>>,
481481
core: Option<std::ptr::NonNull<dyn Core>>,
482482

483-
/// Number of bytes that can be received by us (sent by the SP)
484-
rx_buf_size: usize,
485-
486-
/// Number of bytes that can be received by Hubris (sent by us)
487-
tx_buf_size: usize,
483+
/// Socket used for communication
484+
socket: Option<HubrisSocket>,
488485

489486
/// If we receive an RPC result, then record the buffer here
490487
results: Vec<Vec<u8>>,
@@ -498,8 +495,7 @@ impl<'a> HiffyContext<'a> {
498495
HiffySendWorkspace {
499496
hubris: None,
500497
core: None,
501-
rx_buf_size: 0,
502-
tx_buf_size: 0,
498+
socket: None,
503499
results: vec![],
504500
errors: vec![],
505501
});
@@ -563,8 +559,9 @@ impl<'a> HiffyContext<'a> {
563559
)
564560
}
565561
};
562+
let socket = workspace.socket.as_ref().unwrap();
566563

567-
let mut buf = vec![0u8; workspace.rx_buf_size];
564+
let mut buf = vec![0u8; socket.tx.bytes];
568565
let image_id = hubris.image_id().unwrap();
569566

570567
let header = RpcHeader {
@@ -577,11 +574,11 @@ impl<'a> HiffyContext<'a> {
577574

578575
let mut packet = header.as_bytes().to_vec();
579576
packet.extend(&payload[0..nbytes as usize]);
580-
if packet.len() > workspace.tx_buf_size {
577+
if packet.len() > socket.rx.bytes {
581578
let e = anyhow!(
582579
"packet length {} exceeds tx buf size {}",
583580
packet.len(),
584-
workspace.tx_buf_size
581+
socket.rx.bytes,
585582
);
586583
workspace.errors.push(e);
587584
return Err(Failure::FunctionError(0));
@@ -685,8 +682,7 @@ impl<'a> HiffyContext<'a> {
685682
.unwrap(),
686683
),
687684

688-
rx_buf_size: udprpc.tx.bytes,
689-
tx_buf_size: udprpc.rx.bytes,
685+
socket: Some(udprpc.clone()),
690686
results: vec![],
691687
errors: vec![],
692688
};

0 commit comments

Comments
 (0)