Bug 891551 - Part 9: ignore initial socket connect failures during gathering. r=jesup
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Thu, 18 Jun 2015 23:02:25 -0700
changeset 280475 39c0d32001d77f77ce62d19fad3341366d5edef7
parent 280474 a468baf1358efbcd15bfebcdad90108e178cc573
child 280476 3d754c9848d6170dec2929f54131668610d6fd3c
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs891551
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 891551 - Part 9: ignore initial socket connect failures during gathering. r=jesup
media/mtransport/test/ice_unittest.cpp
media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -58,19 +58,19 @@ extern "C" {
 
 using namespace mozilla;
 MtransportTestUtils *test_utils;
 
 bool stream_added = false;
 
 static unsigned int kDefaultTimeout = 7000;
 
-const std::string kDefaultStunServerAddress((char *)"23.21.150.121");
+const std::string kDefaultStunServerAddress((char *)"107.23.150.92");
 const std::string kDefaultStunServerHostname(
-    (char *)"stun.services.mozilla.com");
+    (char *)"stun.stunprotocol.org");
 const std::string kBogusStunServerHostname(
     (char *)"stun-server-nonexistent.invalid");
 const uint16_t kDefaultStunServerPort=3478;
 const std::string kBogusIceCandidate(
     (char *)"candidate:0 2 UDP 2113601790 192.168.178.20 50769 typ");
 
 const std::string kUnreachableHostIceCandidate(
     (char *)"candidate:0 1 UDP 2113601790 192.168.178.20 50769 typ host");
@@ -1570,16 +1570,26 @@ TEST_F(IceGatherTest, TestGatherFakeStun
     return;
   }
 
   EnsurePeer();
   peer_->SetStunServer(g_stun_server_hostname, kDefaultStunServerPort);
   Gather();
 }
 
+TEST_F(IceGatherTest, TestGatherFakeStunServerTcpHostnameNoResolver) {
+  if (g_stun_server_hostname.empty()) {
+    return;
+  }
+
+  EnsurePeer();
+  peer_->SetStunServer(g_stun_server_hostname, kDefaultStunServerPort, kNrIceTransportTcp);
+  Gather();
+}
+
 TEST_F(IceGatherTest, TestGatherFakeStunServerIpAddress) {
   if (g_stun_server_address.empty()) {
     return;
   }
 
   EnsurePeer();
   peer_->SetStunServer(g_stun_server_address, kDefaultStunServerPort);
   peer_->SetFakeResolver();
--- a/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c
+++ b/media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c
@@ -156,48 +156,51 @@ static nr_socket_vtbl nr_socket_multi_tc
   0
 };
 
 static int nr_socket_multi_tcp_create_stun_server_socket(
   nr_socket_multi_tcp *sock, nr_ice_stun_server * stun_server,
   nr_transport_addr *addr, int max_pending)
   {
     int r, _status;
-    nr_tcp_socket_ctx *tcp_socket_ctx;
+    nr_tcp_socket_ctx *tcp_socket_ctx=0;
     nr_socket * nrsock;
 
     if (stun_server->transport!=IPPROTO_TCP)
-      return(0);
+      ABORT(R_BAD_ARGS);
 
     if ((r=nr_socket_factory_create_socket(sock->ctx->socket_factory,addr, &nrsock)))
       ABORT(r);
 
     /* This takes ownership of nrsock whether it fails or not. */
     if ((r=nr_tcp_socket_ctx_create(nrsock, 0, max_pending, &tcp_socket_ctx)))
       ABORT(r);
 
-    TAILQ_INSERT_TAIL(&sock->sockets, tcp_socket_ctx, entry);
-
     if (stun_server->type == NR_ICE_STUN_SERVER_TYPE_ADDR) {
       nr_transport_addr stun_server_addr;
 
       nr_transport_addr_copy(&stun_server_addr, &stun_server->u.addr);
       r=nr_socket_connect(tcp_socket_ctx->inner, &stun_server_addr);
       if (r && r!=R_WOULDBLOCK) {
-        r_log(LOG_ICE,LOG_DEBUG,"%s:%d function %s connect to STUN server(addr:%s) failed with error %d",__FILE__,__LINE__,__FUNCTION__,stun_server_addr.as_string,_status);
+        r_log(LOG_ICE,LOG_WARNING,"%s:%d function %s connect to STUN server(addr:%s) failed with error %d",__FILE__,__LINE__,__FUNCTION__,stun_server_addr.as_string,r);
         ABORT(r);
       }
 
       if ((r=nr_tcp_socket_ctx_initialize(tcp_socket_ctx, &stun_server_addr, sock)))
         ABORT(r);
     }
+
+    TAILQ_INSERT_TAIL(&sock->sockets, tcp_socket_ctx, entry);
+
     _status=0;
   abort:
-    if (_status)
+    if (_status) {
+      nr_tcp_socket_ctx_destroy(&tcp_socket_ctx);
       r_log(LOG_ICE,LOG_DEBUG,"%s:%d function %s(addr:%s) failed with error %d",__FILE__,__LINE__,__FUNCTION__,addr->as_string,_status);
+    }
     return(_status);
   }
 
 int nr_socket_multi_tcp_create(struct nr_ice_ctx_ *ctx,
     nr_transport_addr *addr, nr_socket_tcp_type tcp_type,
     int precreated_so_count, int use_framing, int max_pending,
     nr_socket **sockp)
   {
@@ -221,25 +224,31 @@ int nr_socket_multi_tcp_create(struct nr
     if((tcp_type==TCP_TYPE_PASSIVE) &&
       ((r=nr_socket_factory_create_socket(sock->ctx->socket_factory, addr, &sock->listen_socket))))
       ABORT(r);
 
     if (tcp_type!=TCP_TYPE_ACTIVE) {
       if (sock->ctx && sock->ctx->stun_servers) {
         for (i=0; i<sock->ctx->stun_server_ct; ++i) {
           if ((r=nr_socket_multi_tcp_create_stun_server_socket(sock,
-              sock->ctx->stun_servers+i, addr, max_pending)))
-            ABORT(r);
+              sock->ctx->stun_servers+i, addr, max_pending))) {
+            if (r!=R_BAD_ARGS) {
+              r_log(LOG_ICE,LOG_WARNING,"%s:%d function %s failed to connect STUN server from addr:%s with error %d",__FILE__,__LINE__,__FUNCTION__,addr->as_string,r);
+            }
+          }
         }
       }
       if (sock->ctx && sock->ctx->turn_servers) {
         for (i=0; i<sock->ctx->turn_server_ct; ++i) {
           if ((r=nr_socket_multi_tcp_create_stun_server_socket(sock,
-              &(sock->ctx->turn_servers[i]).turn_server, addr, max_pending)))
-            ABORT(r);
+              &(sock->ctx->turn_servers[i]).turn_server, addr, max_pending))) {
+            if (r!=R_BAD_ARGS) {
+              r_log(LOG_ICE,LOG_WARNING,"%s:%d function %s failed to connect TURN server from addr:%s with error %d",__FILE__,__LINE__,__FUNCTION__,addr->as_string,r);
+            }
+          }
         }
       }
     }
 
     if ((tcp_type==TCP_TYPE_SO)) {
       for (i=0; i<precreated_so_count; ++i) {
 
         if ((r=nr_socket_factory_create_socket(sock->ctx->socket_factory, addr, &nrsock)))