зеркало из https://github.com/mozilla/gecko-dev.git
Bug 891551 - Part 9: ignore initial socket connect failures during gathering. r=jesup
This commit is contained in:
Родитель
72a87d1ac6
Коммит
2ca1bfcdb2
|
@ -63,9 +63,9 @@ bool stream_added = false;
|
||||||
|
|
||||||
static unsigned int kDefaultTimeout = 7000;
|
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(
|
const std::string kDefaultStunServerHostname(
|
||||||
(char *)"stun.services.mozilla.com");
|
(char *)"stun.stunprotocol.org");
|
||||||
const std::string kBogusStunServerHostname(
|
const std::string kBogusStunServerHostname(
|
||||||
(char *)"stun-server-nonexistent.invalid");
|
(char *)"stun-server-nonexistent.invalid");
|
||||||
const uint16_t kDefaultStunServerPort=3478;
|
const uint16_t kDefaultStunServerPort=3478;
|
||||||
|
@ -1575,6 +1575,16 @@ TEST_F(IceGatherTest, TestGatherFakeStunServerHostnameNoResolver) {
|
||||||
Gather();
|
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) {
|
TEST_F(IceGatherTest, TestGatherFakeStunServerIpAddress) {
|
||||||
if (g_stun_server_address.empty()) {
|
if (g_stun_server_address.empty()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -161,11 +161,11 @@ static int nr_socket_multi_tcp_create_stun_server_socket(
|
||||||
nr_transport_addr *addr, int max_pending)
|
nr_transport_addr *addr, int max_pending)
|
||||||
{
|
{
|
||||||
int r, _status;
|
int r, _status;
|
||||||
nr_tcp_socket_ctx *tcp_socket_ctx;
|
nr_tcp_socket_ctx *tcp_socket_ctx=0;
|
||||||
nr_socket * nrsock;
|
nr_socket * nrsock;
|
||||||
|
|
||||||
if (stun_server->transport!=IPPROTO_TCP)
|
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)))
|
if ((r=nr_socket_factory_create_socket(sock->ctx->socket_factory,addr, &nrsock)))
|
||||||
ABORT(r);
|
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)))
|
if ((r=nr_tcp_socket_ctx_create(nrsock, 0, max_pending, &tcp_socket_ctx)))
|
||||||
ABORT(r);
|
ABORT(r);
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&sock->sockets, tcp_socket_ctx, entry);
|
|
||||||
|
|
||||||
if (stun_server->type == NR_ICE_STUN_SERVER_TYPE_ADDR) {
|
if (stun_server->type == NR_ICE_STUN_SERVER_TYPE_ADDR) {
|
||||||
nr_transport_addr stun_server_addr;
|
nr_transport_addr stun_server_addr;
|
||||||
|
|
||||||
nr_transport_addr_copy(&stun_server_addr, &stun_server->u.addr);
|
nr_transport_addr_copy(&stun_server_addr, &stun_server->u.addr);
|
||||||
r=nr_socket_connect(tcp_socket_ctx->inner, &stun_server_addr);
|
r=nr_socket_connect(tcp_socket_ctx->inner, &stun_server_addr);
|
||||||
if (r && r!=R_WOULDBLOCK) {
|
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);
|
ABORT(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((r=nr_tcp_socket_ctx_initialize(tcp_socket_ctx, &stun_server_addr, sock)))
|
if ((r=nr_tcp_socket_ctx_initialize(tcp_socket_ctx, &stun_server_addr, sock)))
|
||||||
ABORT(r);
|
ABORT(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TAILQ_INSERT_TAIL(&sock->sockets, tcp_socket_ctx, entry);
|
||||||
|
|
||||||
_status=0;
|
_status=0;
|
||||||
abort:
|
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);
|
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);
|
return(_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,15 +229,21 @@ int nr_socket_multi_tcp_create(struct nr_ice_ctx_ *ctx,
|
||||||
if (sock->ctx && sock->ctx->stun_servers) {
|
if (sock->ctx && sock->ctx->stun_servers) {
|
||||||
for (i=0; i<sock->ctx->stun_server_ct; ++i) {
|
for (i=0; i<sock->ctx->stun_server_ct; ++i) {
|
||||||
if ((r=nr_socket_multi_tcp_create_stun_server_socket(sock,
|
if ((r=nr_socket_multi_tcp_create_stun_server_socket(sock,
|
||||||
sock->ctx->stun_servers+i, addr, max_pending)))
|
sock->ctx->stun_servers+i, addr, max_pending))) {
|
||||||
ABORT(r);
|
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) {
|
if (sock->ctx && sock->ctx->turn_servers) {
|
||||||
for (i=0; i<sock->ctx->turn_server_ct; ++i) {
|
for (i=0; i<sock->ctx->turn_server_ct; ++i) {
|
||||||
if ((r=nr_socket_multi_tcp_create_stun_server_socket(sock,
|
if ((r=nr_socket_multi_tcp_create_stun_server_socket(sock,
|
||||||
&(sock->ctx->turn_servers[i]).turn_server, addr, max_pending)))
|
&(sock->ctx->turn_servers[i]).turn_server, addr, max_pending))) {
|
||||||
ABORT(r);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче