Repeated keystore creations leak file descriptors
With sequoia-keystore
0.7.0
, on macOS, the following
#[test]
fn repeated_keystore() {
let keystore_dir = tempfile::tempdir().unwrap();
let context = sequoia_keystore::Context::configure()
.home(&keystore_dir.path())
.build()
.unwrap();
for _ in 0..1000 {
let keystore = match sequoia_keystore::Keystore::connect(&context) {
Ok(m) => m,
Err(e) => {
eprintln!("FAILED: PID {}: {}", std::process::id(), e);
std::thread::sleep(std::time::Duration::from_secs(1000)); // To allow listing open files
unreachable!()
}
};
drop(keystore);
}
}
fails, typically with “Too many open files”. lsof
shows many kqueue file descriptors, and some TCP sockets listening on localhost ports.
(Filing this early, in case the cause were obvious to someone. I’ll continue investigating.)
Cc: @dueno