Skip to content

Commit cef3250

Browse files
committed
FreeBSD: sleep after creating hotplug socket
This works around the issue described in #13
1 parent 3d5452d commit cef3250

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/hotplug/freebsd.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use std::{
77
unix::ffi::OsStrExt,
88
},
99
path::PathBuf,
10+
thread,
11+
time::Duration,
1012
};
1113

1214
use libc::{AF_UNIX, SOCK_CLOEXEC, SOCK_SEQPACKET, connect, recv, sockaddr_un, socket, ssize_t};
@@ -68,6 +70,13 @@ impl super::HotplugImpl for Impl {
6870
mem::size_of_val(&addr) as _,
6971
))?;
7072

73+
// `devd` in FreeBSD 14 has a race condition where it will send out device events
74+
// *before* accepting new incoming client connections, which can cause us to miss an
75+
// event if we're immediately creating a `UinputDevice` after the `HotplugMonitor`
76+
// (which the test suite does).
77+
// Sleeping for a bit here largely works around that.
78+
thread::sleep(Duration::from_millis(25));
79+
7180
Ok(Self { fd })
7281
}
7382
}

0 commit comments

Comments
 (0)