Bug 1037618 - Part 1: Add some logging to highlight TCP connection failures. r=drno
authorByron Campen [:bwc] <docfaraday@gmail.com>
Tue, 01 Mar 2016 12:06:12 -0600
changeset 322849 73f8e7317425c1c0b28797ad9142a21d5971b561
parent 322848 a463f2cf51e32ec25040a7cff2790f43dbf3344c
child 322850 b71d9316ae2294c8745fc3bdf2ac8ba2479a53b9
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno
bugs1037618
milestone47.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 1037618 - Part 1: Add some logging to highlight TCP connection failures. r=drno MozReview-Commit-ID: 4q84yGspvyX
media/mtransport/third_party/nICEr/src/net/nr_socket_multi_tcp.c
media/mtransport/third_party/nICEr/src/stun/nr_socket_buffered_stun.c
--- 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
@@ -558,37 +558,45 @@ abort:
   }
 
 static void nr_tcp_multi_lsocket_readable_cb(NR_SOCKET s, int how, void *arg)
   {
     nr_socket_multi_tcp *sock=(nr_socket_multi_tcp *)arg;
     nr_socket *newsock;
     nr_transport_addr remote_addr;
     nr_tcp_socket_ctx *tcp_sock_ctx;
-    int r;
+    int r, _status;
 
     // rearm
     NR_ASYNC_WAIT(s, NR_ASYNC_WAIT_READ, nr_tcp_multi_lsocket_readable_cb, arg);
 
     /* accept */
-    if (nr_socket_accept(sock->listen_socket, &remote_addr, &newsock))
-      return;
+    if ((r=nr_socket_accept(sock->listen_socket, &remote_addr, &newsock)))
+      ABORT(r);
 
     /* This takes ownership of newsock whether it fails or not. */
     if ((r=nr_tcp_socket_ctx_create(newsock, 1, sock->max_pending, &tcp_sock_ctx)))
-      return;
+      ABORT(r);
 
     nr_socket_buffered_set_connected_to(tcp_sock_ctx->inner, &remote_addr);
 
-    if (nr_tcp_socket_ctx_initialize(tcp_sock_ctx, &remote_addr, sock)) {
+    if ((r=nr_tcp_socket_ctx_initialize(tcp_sock_ctx, &remote_addr, sock))) {
       nr_tcp_socket_ctx_destroy(&tcp_sock_ctx);
-      return;
+      ABORT(r);
     }
 
     TAILQ_INSERT_HEAD(&sock->sockets, tcp_sock_ctx, entry);
+
+    _status=0;
+abort:
+    if (_status) {
+      r_log(LOG_ICE,LOG_WARNING,"%s:%d %s failed to accept new TCP connection: %d",__FILE__,__LINE__,__FUNCTION__,_status);
+    } else {
+      r_log(LOG_ICE,LOG_INFO,"%s:%d %s accepted new TCP connection from %s",__FILE__,__LINE__,__FUNCTION__,remote_addr.as_string);
+    }
   }
 
 static int nr_socket_multi_tcp_listen(void *obj, int backlog)
   {
     int r, _status;
     nr_socket_multi_tcp *sock=(nr_socket_multi_tcp *)obj;
     NR_SOCKET fd;
 
@@ -601,12 +609,12 @@ static int nr_socket_multi_tcp_listen(vo
     if ((r=nr_socket_getfd(sock->listen_socket, &fd)))
       ABORT(r);
 
     NR_ASYNC_WAIT(fd, NR_ASYNC_WAIT_READ, nr_tcp_multi_lsocket_readable_cb, sock);
 
     _status=0;
   abort:
     if (_status)
-      r_log(LOG_ICE,LOG_DEBUG,"%s:%d function %s failed with error %d",__FILE__,__LINE__,__FUNCTION__,_status);
+      r_log(LOG_ICE,LOG_WARNING,"%s:%d function %s failed with error %d",__FILE__,__LINE__,__FUNCTION__,_status);
 
     return(_status);
   }
--- 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
@@ -509,19 +509,20 @@ static int nr_socket_buffered_stun_write
     sock->pending += len;
   }
 
   if (sock->pending) {
     if (!already_armed) {
       if ((r=nr_socket_buffered_stun_arm_writable_cb(sock)))
         ABORT(r);
     }
-    r_log(LOG_GENERIC, LOG_INFO, "Write buffer not empty for %s  %u - %s armed (@%p)",
+    r_log(LOG_GENERIC, LOG_INFO, "Write buffer not empty for %s  %u - %s armed (@%p),%s connected",
           sock->remote_addr.as_string, (uint32_t)sock->pending,
-          already_armed ? "already" : "", &sock->pending);
+          already_armed ? "already" : "", &sock->pending,
+          sock->connected ? "" : " not");
   }
 
   *written = original_len;
 
   _status=0;
 abort:
   return _status;
 }