Skip to content

Commit

Permalink
Merge pull request #322 from ettancos/main
Browse files Browse the repository at this point in the history
guard against unnecessary blocking read if there is no payload
  • Loading branch information
LGFae committed May 31, 2024
2 parents c1ecdb0 + 2cf04e3 commit e57b9b4
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions daemon/src/wayland/wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,19 @@ impl WireMsg {

let mut payload = vec![0u32; size >> 2];

// this should not fail with INTR, because otherwise our socket's internal buffer will
// be left in an inconsistent state (a message without a header)
rustix::io::retry_on_intr(|| {
let iov = io::IoSliceMut::new(u32_slice_to_u8_mut(&mut payload));
net::recvmsg(
wayland_fd(),
&mut [iov],
&mut control,
net::RecvFlags::WAITALL,
)
})?;
if size > 0 {
// this should not fail with INTR, because otherwise our socket's internal buffer will
// be left in an inconsistent state (a message without a header)
rustix::io::retry_on_intr(|| {
let iov = io::IoSliceMut::new(u32_slice_to_u8_mut(&mut payload));
net::recvmsg(
wayland_fd(),
&mut [iov],
&mut control,
net::RecvFlags::WAITALL,
)
})?;
}

Ok((
Self {
Expand Down

0 comments on commit e57b9b4

Please sign in to comment.