From 2ca1bfcdb2390c6153ae8725c2b0bfa5205221fa Mon Sep 17 00:00:00 2001 From: "Nils Ohlmeier [:drno]" Date: Thu, 18 Jun 2015 23:02:25 -0700 Subject: [PATCH] Bug 891551 - Part 9: ignore initial socket connect failures during gathering. r=jesup --- media/mtransport/test/ice_unittest.cpp | 14 +++++++-- .../nICEr/src/net/nr_socket_multi_tcp.c | 29 ++++++++++++------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/media/mtransport/test/ice_unittest.cpp b/media/mtransport/test/ice_unittest.cpp index eb1ca57694ae..3087fce6a2a1 100644 --- a/media/mtransport/test/ice_unittest.cpp +++ b/media/mtransport/test/ice_unittest.cpp @@ -63,9 +63,9 @@ 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; @@ -1575,6 +1575,16 @@ TEST_F(IceGatherTest, TestGatherFakeStunServerHostnameNoResolver) { 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; diff --git 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 index c901d0bc1bff..63e45f069a79 100644 --- 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 @@ -161,11 +161,11 @@ static int nr_socket_multi_tcp_create_stun_server_socket( 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); @@ -174,25 +174,28 @@ static int nr_socket_multi_tcp_create_stun_server_socket( 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); } @@ -226,15 +229,21 @@ int nr_socket_multi_tcp_create(struct nr_ice_ctx_ *ctx, if (sock->ctx && sock->ctx->stun_servers) { for (i=0; ictx->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; ictx->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); + } + } } } }