From 6dc6ad0e038f75075e2f1972d335563760dec4ef Mon Sep 17 00:00:00 2001 From: Tor Brede Vekterli Date: Wed, 6 Feb 2019 14:17:18 +0000 Subject: Debug log connection peer spec on handshake Keeping this at debug level for now, but at least the information is readily available. --- fnet/src/vespa/fnet/connection.cpp | 9 ++++++++- fnet/src/vespa/fnet/connection.h | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'fnet/src') diff --git a/fnet/src/vespa/fnet/connection.cpp b/fnet/src/vespa/fnet/connection.cpp index e028afe5deb..1a5834d6e96 100644 --- a/fnet/src/vespa/fnet/connection.cpp +++ b/fnet/src/vespa/fnet/connection.cpp @@ -218,11 +218,12 @@ FNET_Connection::handshake() bool broken = false; switch (_socket->handshake()) { case vespalib::CryptoSocket::HandshakeResult::FAIL: - LOG(debug, "Connection(%s): handshake failed", GetSpec()); + LOG(debug, "Connection(%s): handshake failed with peer %s", GetSpec(), GetPeerSpec().c_str()); SetState(FNET_CLOSED); broken = true; break; case vespalib::CryptoSocket::HandshakeResult::DONE: { + LOG(debug, "Connection(%s): handshake done with peer %s", GetSpec(), GetPeerSpec().c_str()); EnableReadEvent(true); EnableWriteEvent(writePendingAfterConnect()); _flags._framed = (_socket->min_read_buffer_size() > 1); @@ -752,3 +753,9 @@ FNET_Connection::HandleWriteEvent() } return !broken; } + +vespalib::string +FNET_Connection::GetPeerSpec() const +{ + return vespalib::SocketAddress::peer_address(_socket->get_fd()).spec(); +} diff --git a/fnet/src/vespa/fnet/connection.h b/fnet/src/vespa/fnet/connection.h index 44ad3fea97d..40f826243bf 100644 --- a/fnet/src/vespa/fnet/connection.h +++ b/fnet/src/vespa/fnet/connection.h @@ -230,6 +230,11 @@ private: bool Write(); bool writePendingAfterConnect(); + + /** + * @return address spec of socket peer. Only makes sense to call on non-listening sockets. + */ + vespalib::string GetPeerSpec() const; public: /** -- cgit v1.2.3