rate_limiter: add a safety comment

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2022-11-16 21:29:58 +00:00 committed by Liu Wei
parent b1efa5b26b
commit 58b7057c7f

View File

@ -343,6 +343,7 @@ impl RateLimiter {
let timer_fd = TimerFd::new()?; let timer_fd = TimerFd::new()?;
// Note: vmm_sys_util::TimerFd::new() open the fd w/o O_NONBLOCK. We manually add this flag // Note: vmm_sys_util::TimerFd::new() open the fd w/o O_NONBLOCK. We manually add this flag
// so that `Self::event_handler` won't be blocked with `vmm_sys_util::TimerFd::wait()`. // so that `Self::event_handler` won't be blocked with `vmm_sys_util::TimerFd::wait()`.
// SAFETY: FFI calls.
let ret = unsafe { let ret = unsafe {
let fd = timer_fd.as_raw_fd(); let fd = timer_fd.as_raw_fd();
let mut flags = libc::fcntl(fd, libc::F_GETFL); let mut flags = libc::fcntl(fd, libc::F_GETFL);