Skip to content

Commit

Permalink
TCPServer: more informative error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Aug 27, 2022
1 parent e6030dc commit 4733d42
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/tcp_server.inl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void TCPServer<READ_BUF_SIZE, WRITE_BUF_SIZE>::start_listening(const std::string

err = uv_tcp_bind(socket, reinterpret_cast<sockaddr*>(&addr6), UV_TCP_IPV6ONLY);
if (err) {
LOGERR(1, "failed to bind tcp server IPv6 socket, error " << uv_err_name(err));
LOGERR(1, "failed to bind tcp server IPv6 socket " << address << ", error " << uv_err_name(err));
panic();
}
}
Expand All @@ -199,14 +199,14 @@ void TCPServer<READ_BUF_SIZE, WRITE_BUF_SIZE>::start_listening(const std::string

err = uv_tcp_bind(socket, reinterpret_cast<sockaddr*>(&addr), 0);
if (err) {
LOGERR(1, "failed to bind tcp server IPv4 socket, error " << uv_err_name(err));
LOGERR(1, "failed to bind tcp server IPv4 socket " << address << ", error " << uv_err_name(err));
panic();
}
}

err = uv_listen(reinterpret_cast<uv_stream_t*>(socket), DEFAULT_BACKLOG, on_new_connection);
if (err) {
LOGERR(1, "failed to listen on tcp server socket, error " << uv_err_name(err));
LOGERR(1, "failed to listen on tcp server socket " << address << ", error " << uv_err_name(err));
panic();
}

Expand Down Expand Up @@ -395,13 +395,13 @@ bool TCPServer<READ_BUF_SIZE, WRITE_BUF_SIZE>::connect_to_peer_nolock(Client* cl
connect_request->data = client;
err = uv_tcp_connect(connect_request, &client->m_socket, addr, on_connect);
if (err) {
LOGERR(1, "failed to initiate tcp connection, error " << uv_err_name(err));
LOGERR(1, "failed to initiate tcp connection to " << static_cast<const char*>(client->m_addrString) << ", error " << uv_err_name(err));
m_pendingConnections.erase(client->m_addr);
uv_close(reinterpret_cast<uv_handle_t*>(&client->m_socket), on_connection_error);
return false;
}
else {
LOGINFO(5, "connecting to " << log::Gray() << static_cast<char*>(client->m_addrString));
LOGINFO(5, "connecting to " << log::Gray() << static_cast<const char*>(client->m_addrString));
}

return true;
Expand Down

0 comments on commit 4733d42

Please sign in to comment.