so, that was a B7, not an 87. hours of my life gone, because of two pixels

This commit is contained in:
Ryan Heywood 2025-07-11 21:06:27 -04:00
parent d942d615d5
commit c388eb1fc5
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 9 additions and 7 deletions

View File

@ -13,7 +13,7 @@ impl std::fmt::Display for InvalidHeartbeatResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!( write!(
f, f,
"Invalid heartbeat response: expected 0x87, got 0x{}", "Invalid heartbeat response: expected 0xB7, got 0x{}",
self.0 self.0
) )
} }
@ -31,9 +31,10 @@ impl Aws {
svm_family: SocketFamily::Vsock as u16, svm_family: SocketFamily::Vsock as u16,
svm_port: 9000, svm_port: 9000,
svm_cid: 3, svm_cid: 3,
..(unsafe { std::mem::zeroed() }) svm_reserved1: 0,
svm_zero: [0; 4],
}; };
let mut buf = [0x87]; let mut buf = [0xB7];
let fd = socket(SocketFamily::Vsock, SocketType::Stream)?; let fd = socket(SocketFamily::Vsock, SocketType::Stream)?;
unsafe { unsafe {
@ -43,11 +44,12 @@ impl Aws {
std::mem::size_of_val(&sockaddr), std::mem::size_of_val(&sockaddr),
)?; )?;
}; };
dbg!(write(fd, &buf));
dbg!(read(fd, &mut buf));
dbg!(close(fd));
if buf[0] != 0x87 { write(fd, &buf)?;
read(fd, &mut buf)?;
close(fd)?;
if buf[0] != 0xB7 {
return Err(InvalidHeartbeatResponse(buf[0])) return Err(InvalidHeartbeatResponse(buf[0]))
.context(format_args!("Bad value from heartbeat")); .context(format_args!("Bad value from heartbeat"));
} }