Do not spam "Connect failed with 101/65" in logs.
WebRTC polls the list of local IP addresses for both IPv4 and IPv6
every ~2 seconds. It does so by trying to connect() a UDP socket to
an address on the public Internet (without actually sending any
packets).
If the host doesn't have IPv6 (or IPv4) connectivity, it fails with
errno 101 (ENETUNREACH, Linux) or errno 65 (EHOSTUNREACH, Mac).
This is the expected behavior, and we shouldn't be logging these
failures, especially since polling is fairly frequent.
BUG=webrtc:6347
R=deadbeef@webrtc.org, honghaiz@webrtc.org, perkj@webrtc.org
Review URL: https://codereview.webrtc.org/2370383002 .
Cr-Commit-Position: refs/heads/master@{#14440}
diff --git a/webrtc/base/network.cc b/webrtc/base/network.cc
index 36d028b..ba056e4 100644
--- a/webrtc/base/network.cc
+++ b/webrtc/base/network.cc
@@ -839,7 +839,12 @@
if (socket->Connect(SocketAddress(
family == AF_INET ? kPublicIPv4Host : kPublicIPv6Host, kPublicPort)) <
0) {
- LOG(LS_INFO) << "Connect failed with " << socket->GetError();
+ if (socket->GetError() != ENETUNREACH
+ && socket->GetError() != EHOSTUNREACH) {
+ // Ignore the expected case of "host/net unreachable" - which happens if
+ // the network is V4- or V6-only.
+ LOG(LS_INFO) << "Connect failed with " << socket->GetError();
+ }
return IPAddress();
}
return socket->GetLocalAddress().ipaddr();