Skip to content

Commit

Permalink
Fix port_getn calling. (#1215)
Browse files Browse the repository at this point in the history
* Fix `port_getn` calling.

* Return immediately if the vector's capacity is 0.
  • Loading branch information
Berrysoft authored and sunfishcode committed Nov 18, 2024
1 parent 7777f6b commit 92bb625
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/backend/libc/event/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,15 @@ pub(crate) fn port_getn(
events: &mut Vec<Event>,
mut nget: u32,
) -> io::Result<()> {
if events.capacity() == 0 {
return Ok(());
}
let timeout = timeout.map_or(null_mut(), as_mut_ptr);
unsafe {
ret(c::port_getn(
borrowed_fd(port),
events.as_mut_ptr().cast(),
events.len().try_into().unwrap(),
events.capacity().try_into().unwrap(),
&mut nget,
timeout,
))?;
Expand Down

0 comments on commit 92bb625

Please sign in to comment.