Bug 1023539: Fix occasional timeouts of TURN webrtc transports with one-way connections r=bwc a=lmandel
authorPaul Kerr [:pkerr] <pkerr@mozilla.com>
Thu, 06 Nov 2014 15:03:41 -0800
changeset 226001 d73c4671a18f
parent 226000 2231ed05a1b8
child 226004 00f9c65b2f83
push id4103
push userrjesup@wgate.com
push date2014-11-10 14:16 +0000
treeherdermozilla-beta@d73c4671a18f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc, lmandel
bugs1023539
milestone34.0
Bug 1023539: Fix occasional timeouts of TURN webrtc transports with one-way connections r=bwc a=lmandel Run TURN relay reservation refresh logic when handling a Data Indication packet
media/mtransport/third_party/nICEr/src/stun/turn_client_ctx.c
--- a/media/mtransport/third_party/nICEr/src/stun/turn_client_ctx.c
+++ b/media/mtransport/third_party/nICEr/src/stun/turn_client_ctx.c
@@ -58,16 +58,21 @@ int NR_LOG_TURN = 0;
 #define TURN_USECS_PER_S                 1000000
 #define TURN_REFRESH_SLACK_SECONDS       10    /* How long before expiry to refresh
                                                   allocations/permissions. The RFC 5766
                                                   Section 7 recommendation if 60 seconds,
                                                   but this is silly since the transaction
                                                   times out after about 5. */
 #define TURN_PERMISSION_LIFETIME_SECONDS 300   /* 5 minutes. From RFC 5766 2.3 */
 
+// Set to enable a temporary fix that will run the TURN reservation keep-alive
+// logic when data is received via a TURN relayed path: a DATA_INDICATION packet is received.
+// TODO(pkerr@mozilla.com) This should be replace/removed when bug 935806 is implemented.
+#define REFRESH_RESERVATION_ON_RECV 1
+
 static int nr_turn_stun_ctx_create(nr_turn_client_ctx *tctx, int type,
                                    NR_async_cb success_cb,
                                    NR_async_cb failure_cb,
                                    nr_turn_stun_ctx **ctxp);
 static int nr_turn_stun_ctx_destroy(nr_turn_stun_ctx **ctxp);
 static void nr_turn_stun_ctx_cb(NR_SOCKET s, int how, void *arg);
 static int nr_turn_stun_set_auth_params(nr_turn_stun_ctx *ctx,
                                         char *realm, char *nonce);
@@ -785,16 +790,22 @@ int nr_turn_client_parse_data_indication
     }
     ABORT(r);
   }
 
   if ((r=nr_transport_addr_copy(remote_addr,
                                 &attr->u.xor_mapped_address.unmasked)))
     ABORT(r);
 
+#if REFRESH_RESERVATION_ON_RECV
+  if ((r=nr_turn_client_ensure_perm(ctx, remote_addr))) {
+    ABORT(r);
+  }
+#endif
+
   if (!nr_stun_message_has_attribute(ind, NR_STUN_ATTR_DATA, &attr)) {
     ABORT(R_BAD_DATA);
   }
 
   assert(newsize >= attr->u.data.length);
   if (newsize < attr->u.data.length)
     ABORT(R_BAD_ARGS);