Skip to content

Commit

Permalink
Merge pull request #15 from nivkner/socklen
Browse files Browse the repository at this point in the history
libc 0.2.42 changed definition of bind to use socklen_t on aarch64-linux-android
  • Loading branch information
alexcrichton authored Jun 27, 2018
2 parents bf2bf84 + fb35f90 commit e1e43ff
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ travis-ci = { repository = "alexcrichton/mio-uds" }

[target."cfg(unix)".dependencies]
iovec = "0.1"
libc = "0.2"
libc = "0.2.42"
mio = "0.6.5"

[dev-dependencies]
Expand Down
3 changes: 1 addition & 2 deletions src/datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use mio::unix::EventedFd;
use mio::{Poll, Token, Ready, PollOpt};

use cvt;
use Len;
use socket::{sockaddr_un, Socket};

/// A Unix datagram socket.
Expand All @@ -31,7 +30,7 @@ impl UnixDatagram {
let fd = try!(Socket::new(libc::SOCK_DGRAM));

let addr = &addr as *const _ as *const _;
try!(cvt(libc::bind(fd.fd(), addr, len as Len)));
try!(cvt(libc::bind(fd.fd(), addr, len as libc::socklen_t)));

Ok(UnixDatagram::from_raw_fd(fd.into_fd()))
}
Expand Down
6 changes: 0 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ pub use stream::UnixStream;
pub use listener::UnixListener;
pub use datagram::UnixDatagram;

#[cfg(not(all(target_arch = "aarch64",target_os = "android")))]
type Len = libc::socklen_t;
// Match Android weirdness for aarch64 found in libc.
#[cfg(all(target_arch = "aarch64",target_os = "android"))]
type Len = libc::c_int;

fn cvt(i: libc::c_int) -> io::Result<libc::c_int> {
if i == -1 {
Err(io::Error::last_os_error())
Expand Down
3 changes: 1 addition & 2 deletions src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use mio::{Poll, PollOpt, Ready, Token};

use UnixStream;
use cvt;
use Len;
use socket::{sockaddr_un, Socket};

/// A structure representing a Unix domain socket server.
Expand All @@ -35,7 +34,7 @@ impl UnixListener {
let fd = try!(Socket::new(libc::SOCK_STREAM));

let addr = &addr as *const _ as *const _;
try!(cvt(libc::bind(fd.fd(), addr, len as Len)));
try!(cvt(libc::bind(fd.fd(), addr, len as libc::socklen_t)));
try!(cvt(libc::listen(fd.fd(), 128)));

Ok(UnixListener::from_raw_fd(fd.into_fd()))
Expand Down

0 comments on commit e1e43ff

Please sign in to comment.