Skip to content

Commit 0565616

Browse files
authored
Fix port_getn calling. (#1215)
* Fix `port_getn` calling. * Return immediately if the vector's capacity is 0.
1 parent 3b9948a commit 0565616

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/backend/libc/event/syscalls.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,15 @@ pub(crate) fn port_getn(
314314
events: &mut Vec<Event>,
315315
mut nget: u32,
316316
) -> io::Result<()> {
317+
if events.capacity() == 0 {
318+
return Ok(());
319+
}
317320
let timeout = timeout.map_or(null_mut(), as_mut_ptr);
318321
unsafe {
319322
ret(c::port_getn(
320323
borrowed_fd(port),
321324
events.as_mut_ptr().cast(),
322-
events.len().try_into().unwrap(),
325+
events.capacity().try_into().unwrap(),
323326
&mut nget,
324327
timeout,
325328
))?;

0 commit comments

Comments
 (0)