diff options
author | Wan-Teh Chang <wtc@google.com> | 2014-01-23 18:38:39 -0800 |
---|---|---|
committer | Wan-Teh Chang <wtc@google.com> | 2014-01-23 18:38:39 -0800 |
commit | 54f39884dd5d6c3dc879915f676f94c8da942abb (patch) | |
tree | 653a73bd52b59e4ba708a0e2e4501e31549558d8 | |
parent | 29a6dd8c902ea7582d00783713b10cca2bfd7b98 (diff) | |
download | nspr-hg-NSPR_4_10_3_BETA3.tar.gz |
Bug 936320: Use an alternative test for IPv6 support on Linux toNSPR_4_10_3_BETA3
avoid opening a socket. r=gdestuynder,
-rw-r--r-- | pr/src/pthreads/ptio.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/pr/src/pthreads/ptio.c b/pr/src/pthreads/ptio.c index 79d58ce8..d31336e1 100644 --- a/pr/src/pthreads/ptio.c +++ b/pr/src/pthreads/ptio.c @@ -3400,8 +3400,6 @@ PR_EXTERN(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc *fd); extern PRBool _pr_ipv6_is_present(void); PR_IMPLEMENT(PRBool) _pr_test_ipv6_socket() { -PRInt32 osfd; - #if defined(DARWIN) /* * Disable IPv6 if Darwin version is less than 7.0.0 (OS X 10.3). IPv6 on @@ -3414,18 +3412,24 @@ PRInt32 osfd; } #endif +#if defined(LINUX) + /* If /proc/net/if_inet6 exists, the Linux kernel supports IPv6. */ + int rv = access("/proc/net/if_inet6", F_OK); + return (rv == 0); +#else /* * HP-UX only: HP-UX IPv6 Porting Guide (dated February 2001) * suggests that we call open("/dev/ip6", O_RDWR) to determine * whether IPv6 APIs and the IPv6 stack are on the system. * Our portable test below seems to work fine, so I am using it. */ - osfd = socket(AF_INET6, SOCK_STREAM, 0); + PRInt32 osfd = socket(AF_INET6, SOCK_STREAM, 0); if (osfd != -1) { close(osfd); return PR_TRUE; } return PR_FALSE; +#endif } #endif /* _PR_INET6_PROBE */ #endif |