Bug 1293206 - Cancel TCP connect callback after connect. r=bwc, a=ritu
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Mon, 15 Aug 2016 10:39:00 -0400
changeset 347671 46e19362c2ba4af8d98ab9e804d014a4ff04d1d6
parent 347670 8d65d9b7e5d2dcfeb773a7b6d4c2030d489ae335
child 347672 523a2b258f62925a61e740bf08ea7890cc272c93
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc, ritu
bugs1293206
milestone50.0a2
Bug 1293206 - Cancel TCP connect callback after connect. r=bwc, a=ritu
media/mtransport/third_party/nICEr/src/stun/nr_socket_buffered_stun.c
--- a/media/mtransport/third_party/nICEr/src/stun/nr_socket_buffered_stun.c
+++ b/media/mtransport/third_party/nICEr/src/stun/nr_socket_buffered_stun.c
@@ -400,24 +400,38 @@ static int nr_socket_buffered_stun_accep
   nr_socket_buffered_stun *bsock = (nr_socket_buffered_stun *)obj;
 
   return nr_socket_accept(bsock->inner, addrp, sockp);
 }
 
 static void nr_socket_buffered_stun_connected_cb(NR_SOCKET s, int how, void *arg)
 {
   nr_socket_buffered_stun *sock = (nr_socket_buffered_stun *)arg;
+  int r, _status;
+  NR_SOCKET fd;
 
   assert(!sock->connected);
 
   sock->connected = 1;
+
+  if ((r=nr_socket_getfd(sock->inner, &fd)))
+    ABORT(r);
+  NR_ASYNC_CANCEL(fd, NR_ASYNC_WAIT_WRITE);
+
   if (sock->pending) {
     r_log(LOG_GENERIC, LOG_INFO, "Invoking writable_cb on connected (%u)", (uint32_t) sock->pending);
     nr_socket_buffered_stun_writable_cb(s, how, arg);
   }
+
+  _status=0;
+abort:
+  if (_status) {
+    r_log(LOG_GENERIC, LOG_ERR, "Failure in nr_socket_buffered_stun_connected_cb: %d", _status);
+
+  }
 }
 
 static int nr_socket_buffered_stun_connect(void *obj, nr_transport_addr *addr)
 {
   nr_socket_buffered_stun *sock = (nr_socket_buffered_stun *)obj;
   int r, _status;
 
   if ((r=nr_transport_addr_copy(&sock->remote_addr, addr)))