test_infra: Avoid file descriptor leak with epoll
Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
00c1b4a95b
commit
4e31206403
1 changed files with 3 additions and 1 deletions
|
|
@ -14,7 +14,7 @@ use std::io::{Read, Write};
|
|||
use std::net::TcpListener;
|
||||
use std::net::TcpStream;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use std::os::unix::io::{AsRawFd, FromRawFd};
|
||||
use std::path::Path;
|
||||
use std::process::{Child, Command, ExitStatus, Output, Stdio};
|
||||
use std::str::FromStr;
|
||||
|
|
@ -82,6 +82,8 @@ impl GuestNetworkConfig {
|
|||
|
||||
// Reply on epoll w/ timeout to wait for guest connections faithfully
|
||||
let epoll_fd = epoll::create(true).expect("Cannot create epoll fd");
|
||||
// Use 'File' to enforce closing on 'epoll_fd'
|
||||
let _epoll_file = unsafe { fs::File::from_raw_fd(epoll_fd) };
|
||||
epoll::ctl(
|
||||
epoll_fd,
|
||||
epoll::ControlOptions::EPOLL_CTL_ADD,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue