Bug 1037618 - Part 1: Add some logging to highlight TCP connection failures. r=drno

MozReview-Commit-ID: 4q84yGspvyX
This commit is contained in:
Byron Campen [:bwc] 2016-03-01 12:06:12 -06:00
parent f374cae3a2
commit d0da0f7767
2 changed files with 18 additions and 9 deletions

View File

@ -563,27 +563,35 @@ static void nr_tcp_multi_lsocket_readable_cb(NR_SOCKET s, int how, void *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)
@ -606,7 +614,7 @@ static int nr_socket_multi_tcp_listen(void *obj, int backlog)
_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);
}

View File

@ -514,9 +514,10 @@ static int nr_socket_buffered_stun_write(void *obj,const void *msg, size_t len,
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;