summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-04-24 14:15:56 +0000
committerbors <bors@rust-lang.org>2018-04-24 14:15:56 +0000
commit38e251ba37231f3471a20a13f503b191ed25a499 (patch)
tree13d4e5496bc54d4c8b64877f39afe32c0bf287e1 /src/libstd/sys
parent2a6200a5c8f19763268f531302ed7ddccf1e7204 (diff)
parentda6142c81057342d8d6686ae4078995aab73b5bc (diff)
downloadrust-38e251ba37231f3471a20a13f503b191ed25a499.tar.gz
rust-38e251ba37231f3471a20a13f503b191ed25a499.zip
Auto merge of #50079 - NickAtAccuPS:android_abstract_socket, r=sfackler
Android abstract unix domain sockets AddressKind correction

The prior check causes abstract unix domain sockets to return AddressKind::Unnamed instead of AddressKind::Abstract on Android.

Other than the immediately proceeding comment "macOS seems to return a len of 16 and a zeroed sun_path for unnamed addresses" the check as-implemented does not seem to have alternative explanation. I couldn't find an alternative explanation while stepping though git blame. I suspect the AddressKind::Unnamed nonzero check should instead be if macos, length 16, and zeroed array. @sfackler could you comment on this, the code as-is is the same from your initial addition of abstract uds support.
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/ext/net.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs
index ba80cbe47c8..e277b1aa7b5 100644
--- a/src/libstd/sys/unix/ext/net.rs
+++ b/src/libstd/sys/unix/ext/net.rs
@@ -214,7 +214,10 @@ impl SocketAddr {
         let path = unsafe { mem::transmute::<&[libc::c_char], &[u8]>(&self.addr.sun_path) };
 
         // macOS seems to return a len of 16 and a zeroed sun_path for unnamed addresses
-        if len == 0 || (cfg!(not(target_os = "linux")) && self.addr.sun_path[0] == 0) {
+        if len == 0
+            || (cfg!(not(any(target_os = "linux", target_os = "android")))
+                && self.addr.sun_path[0] == 0)
+        {
             AddressKind::Unnamed
         } else if self.addr.sun_path[0] == 0 {
             AddressKind::Abstract(&path[1..len])