vhost-user: Fix unit test race condition
The unit tests are run from cargo test through multiple threads of the same process. For this reason, all these threads share their file descriptors (because that's how this works on Linux), which means that any of them can close a file descriptor opened from another thread. In the context of create_listener() and accept_connection() tests, they can run concurrently and this generates some failure when the file descriptor create_listener() is binding to is being closed from the accept_connection() test. In order to avoid such race condition, this patch simply removes the part of the unit test performing an explicit and unsafe file descriptor closure. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
19e14bc77b
commit
09bd21f75e
1 changed files with 0 additions and 10 deletions
|
|
@ -487,7 +487,6 @@ impl<T: Req> AsRawFd for Endpoint<T> {
|
|||
mod tests {
|
||||
|
||||
use super::*;
|
||||
use libc;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Seek, SeekFrom, Write};
|
||||
use std::os::unix::io::FromRawFd;
|
||||
|
|
@ -512,15 +511,6 @@ mod tests {
|
|||
// accept on a fd without incoming connection
|
||||
let conn = listener.accept().unwrap();
|
||||
assert!(conn.is_none());
|
||||
|
||||
listener.set_nonblocking(true).unwrap();
|
||||
|
||||
// accept on a closed fd
|
||||
unsafe {
|
||||
libc::close(listener.as_raw_fd());
|
||||
}
|
||||
let conn2 = listener.accept();
|
||||
assert!(conn2.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue