Skip to content

Commit

Permalink
fix debug assertion of ipc Codes shm fds
Browse files Browse the repository at this point in the history
  • Loading branch information
LGFae committed Aug 8, 2024
1 parent 4851c9b commit 227f83e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions common/src/ipc/transmit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl From<RawMsg> for Answer {

macro_rules! code {
($($name:ident $num:literal),* $(,)?) => {
#[derive(Debug)]
pub enum Code {
$($name,)*
}
Expand Down Expand Up @@ -271,10 +272,14 @@ impl<T> IpcSocket<T> {
let len = u64::from_ne_bytes(buf[8..16].try_into().unwrap()) as usize;

let shm = if len == 0 {
debug_assert!(matches!(
code,
Code::ReqClear | Code::ReqImg | Code::ResInfo
));
debug_assert!(
matches!(
code,
Code::ReqClear | Code::ReqImg | Code::ResInfo | Code::ReqPing | Code::ReqQuery
),
"Received: Code {:?}, which should have sent a shm fd",
code
);
None
} else {
let file = control
Expand Down

0 comments on commit 227f83e

Please sign in to comment.