Compare commits

...

1 Commits

Author SHA1 Message Date
Curt Brune
c61547611c Use epoll_create() directly instead of probing for epoll_create1()
At runtime mio tries to figure out whether to use syscall
epoll_create1() or epoll_create().  However, the Android 4.4 loader
crashes while looking up a symbol that does not
exist (epoll_create1).

More details covered here:
https://users.rust-lang.org/t/libc-dlsym-crashing-on-i686-linux-android/14788

This problem is resolved upstream by commit 479ae7c5e2 ("Cleanup of
sys::unix (#1005)"), but is not yet released officially.

Signed-off-by: Curt Brune <curt@signal.org>
2019-08-29 14:38:29 -07:00

View File

@ -30,21 +30,9 @@ pub struct Selector {
impl Selector {
pub fn new() -> io::Result<Selector> {
let epfd = unsafe {
// Emulate `epoll_create` by using `epoll_create1` if it's available
// and otherwise falling back to `epoll_create` followed by a call to
// set the CLOEXEC flag.
dlsym!(fn epoll_create1(c_int) -> c_int);
match epoll_create1.get() {
Some(epoll_create1_fn) => {
cvt(epoll_create1_fn(libc::EPOLL_CLOEXEC))?
}
None => {
let fd = cvt(libc::epoll_create(1024))?;
drop(set_cloexec(fd));
fd
}
}
let fd = cvt(libc::epoll_create(1024))?;
drop(set_cloexec(fd));
fd
};
// offset by 1 to avoid choosing 0 as the id of a selector