Bug 891551 - Part 8: Increase and make backlog value configurable. r=bwc
authorPeter Tatrai <ptatrai>
Thu, 12 Jun 2014 07:25:00 -0700
changeset 280474 a468baf1358efbcd15bfebcdad90108e178cc573
parent 280473 057cd9bbfbd31655284527a95d66ecbccbb37b8c
child 280475 39c0d32001d77f77ce62d19fad3341366d5edef7
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)
reviewersbwc
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 8: Increase and make backlog value configurable. r=bwc
media/mtransport/nricectx.cpp
media/mtransport/third_party/nICEr/src/ice/ice_component.c
media/mtransport/third_party/nICEr/src/ice/ice_reg.h
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -426,16 +426,17 @@ RefPtr<NrIceCtx> NrIceCtx::Create(const 
       NR_reg_set_uchar((char *)"ice.pref.interface.vmnet8", 234);
       NR_reg_set_uchar((char *)"ice.pref.interface.virbr0", 233);
       NR_reg_set_uchar((char *)"ice.pref.interface.wlan0", 232);
     }
 
     int32_t stun_client_maximum_transmits = 7;
     int32_t ice_trickle_grace_period = 5000;
     int32_t ice_tcp_so_sock_count = 3;
+    int32_t ice_tcp_listen_backlog = 10;
 #ifndef MOZILLA_XPCOMRT_API
     nsresult res;
     nsCOMPtr<nsIPrefService> prefs =
       do_GetService("@mozilla.org/preferences-service;1", &res);
 
     if (NS_SUCCEEDED(res)) {
       nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
       if (branch) {
@@ -443,25 +444,32 @@ RefPtr<NrIceCtx> NrIceCtx::Create(const 
             "media.peerconnection.ice.stun_client_maximum_transmits",
             &stun_client_maximum_transmits);
         branch->GetIntPref(
             "media.peerconnection.ice.trickle_grace_period",
             &ice_trickle_grace_period);
         branch->GetIntPref(
             "media.peerconnection.ice.tcp_so_sock_count",
             &ice_tcp_so_sock_count);
+        branch->GetIntPref(
+            "media.peerconnection.ice.tcp_listen_backlog",
+            &ice_tcp_listen_backlog);
       }
     }
 #endif
     NR_reg_set_uint4((char *)"stun.client.maximum_transmits",
                      stun_client_maximum_transmits);
     NR_reg_set_uint4((char *)NR_ICE_REG_TRICKLE_GRACE_PERIOD,
                      ice_trickle_grace_period);
     NR_reg_set_int4((char *)NR_ICE_REG_ICE_TCP_SO_SOCK_COUNT,
                      ice_tcp_so_sock_count);
+    NR_reg_set_int4((char *)NR_ICE_REG_ICE_TCP_SO_SOCK_COUNT,
+                     ice_tcp_so_sock_count);
+    NR_reg_set_int4((char *)NR_ICE_REG_ICE_TCP_LISTEN_BACKLOG,
+                     ice_tcp_listen_backlog);
 
     if (allow_loopback) {
       NR_reg_set_char((char *)NR_STUN_REG_PREF_ALLOW_LOOPBACK_ADDRS, 1);
     }
   }
 
   // Create the ICE context
   int r;
--- a/media/mtransport/third_party/nICEr/src/ice/ice_component.c
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_component.c
@@ -298,25 +298,25 @@ static int nr_ice_component_initialize_u
   }
 
 static int nr_ice_component_get_port_from_ephemeral_range(uint16_t *port)
   {
     int _status, r;
     void *buf = port;
     if(r=nr_crypto_random_bytes(buf, 2))
       ABORT(r);
-    *port|=0x8000; /* make it >= 0x8000 */
+    *port|=49152; /* make it fit into IANA ephemeral port range >= 49152 */
     _status=0;
 abort:
     return(_status);
   }
 
 static int nr_ice_component_create_tcp_host_candidate(struct nr_ice_ctx_ *ctx,
   nr_ice_component *component, nr_transport_addr *interface_addr, nr_socket_tcp_type tcp_type,
-  int so_sock_ct, char *lufrag, Data *pwd, nr_ice_socket **isock)
+  int backlog, int so_sock_ct, char *lufrag, Data *pwd, nr_ice_socket **isock)
   {
     int r,_status;
     nr_ice_candidate *cand=0;
     int tries=3;
     nr_ice_socket *isock_tmp=0;
     nr_socket *nrsock=0;
     nr_transport_addr addr;
     uint16_t local_port;
@@ -339,17 +339,17 @@ static int nr_ice_component_create_tcp_h
         ABORT(r);
 
       /* It would be better to stop trying if there is error other than
          port already used, but it'd require significant work to support this. */
       r=nr_socket_multi_tcp_create(ctx,&addr,tcp_type,so_sock_ct,1,NR_STUN_MAX_MESSAGE_SIZE,&nrsock);
 
     } while(r);
 
-    if((tcp_type == TCP_TYPE_PASSIVE) && (r=nr_socket_listen(nrsock,1)))
+    if((tcp_type == TCP_TYPE_PASSIVE) && (r=nr_socket_listen(nrsock,backlog)))
       ABORT(r);
 
     if((r=nr_ice_socket_create(ctx,component,nrsock,NR_ICE_SOCKET_TYPE_STREAM_TCP,&isock_tmp)))
       ABORT(r);
 
     /* nr_ice_socket took ownership of nrsock */
     nrsock=NULL;
 
@@ -380,52 +380,58 @@ abort:
 
 static int nr_ice_component_initialize_tcp(struct nr_ice_ctx_ *ctx,nr_ice_component *component, nr_local_addr *addrs, int addr_ct, char *lufrag, Data *pwd)
   {
     nr_ice_candidate *cand=0;
     int i;
     int j;
     int r,_status;
     int so_sock_ct=0;
+    int backlog=10;
 
     r_log(LOG_ICE,LOG_DEBUG,"nr_ice_component_initialize_tcp");
 
     if(r=NR_reg_get_int4(NR_ICE_REG_ICE_TCP_SO_SOCK_COUNT,&so_sock_ct)){
       if(r!=R_NOT_FOUND)
         ABORT(r);
     }
 
+    if(r=NR_reg_get_int4(NR_ICE_REG_ICE_TCP_LISTEN_BACKLOG,&backlog)){
+      if(r!=R_NOT_FOUND)
+        ABORT(r);
+    }
+
     for(i=0;i<addr_ct;i++){
       char suppress;
       nr_ice_socket *isock_psv=0;
       nr_ice_socket *isock_so=0;
 
       if(r=NR_reg_get2_char(NR_ICE_REG_SUPPRESS_INTERFACE_PRFX,addrs[i].addr.ifname,&suppress)){
         if(r!=R_NOT_FOUND)
           ABORT(r);
       }
       else{
         if(suppress)
           continue;
       }
 
       /* passive host candidate */
       if ((r=nr_ice_component_create_tcp_host_candidate(ctx, component, &addrs[i].addr,
-        TCP_TYPE_PASSIVE, 0, lufrag, pwd, &isock_psv)))
+        TCP_TYPE_PASSIVE, backlog, 0, lufrag, pwd, &isock_psv)))
         ABORT(r);
 
       /* active host candidate */
       if ((r=nr_ice_component_create_tcp_host_candidate(ctx, component, &addrs[i].addr,
-        TCP_TYPE_ACTIVE, 0, lufrag, pwd, NULL)))
+        TCP_TYPE_ACTIVE, 0, 0, lufrag, pwd, NULL)))
         ABORT(r);
 
       /* simultaneous-open host candidate */
       if (so_sock_ct) {
         if ((r=nr_ice_component_create_tcp_host_candidate(ctx, component, &addrs[i].addr,
-          TCP_TYPE_SO, so_sock_ct, lufrag, pwd, &isock_so)))
+          TCP_TYPE_SO, 0, so_sock_ct, lufrag, pwd, &isock_so)))
           ABORT(r);
       }
 
       /* And srvrflx candidates for each STUN server */
       for(j=0;j<ctx->stun_server_ct;j++){
         if (ctx->stun_servers[j].transport!=IPPROTO_TCP)
           continue;
 
--- a/media/mtransport/third_party/nICEr/src/ice/ice_reg.h
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_reg.h
@@ -59,16 +59,17 @@ extern "C" {
 #define NR_ICE_REG_TURN_SRV_ADDR            "addr"
 #define NR_ICE_REG_TURN_SRV_PORT            "port"
 #define NR_ICE_REG_TURN_SRV_BANDWIDTH       "bandwidth"
 #define NR_ICE_REG_TURN_SRV_LIFETIME        "lifetime"
 #define NR_ICE_REG_TURN_SRV_USERNAME        "username"
 #define NR_ICE_REG_TURN_SRV_PASSWORD        "password"
 
 #define NR_ICE_REG_ICE_TCP_SO_SOCK_COUNT    "ice.tcp.so_sock_count"
+#define NR_ICE_REG_ICE_TCP_LISTEN_BACKLOG   "ice.tcp.listen_backlog"
 
 #define NR_ICE_REG_KEEPALIVE_TIMER          "ice.keepalive_timer"
 
 #define NR_ICE_REG_TRICKLE_GRACE_PERIOD     "ice.trickle_grace_period"
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 #endif