From ba287cc0fc68e3b48c48f75d99b5a3ae221f9b6b Mon Sep 17 00:00:00 2001 From: klzgrad Date: Mon, 29 Jan 2018 00:16:04 -0500 Subject: [PATCH] Unify connection status logging --- net/tools/naive/naive_client.cc | 11 ++++++----- net/tools/naive/naive_client.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/net/tools/naive/naive_client.cc b/net/tools/naive/naive_client.cc index bcfeb6aec2..522d087b6d 100644 --- a/net/tools/naive/naive_client.cc +++ b/net/tools/naive/naive_client.cc @@ -85,7 +85,7 @@ void NaiveClient::OnConnectComplete(int connection_id, int result) { void NaiveClient::HandleConnectResult(NaiveClientConnection* connection, int result) { if (result != OK) { - Close(connection->id()); + Close(connection->id(), result); return; } DoRun(connection); @@ -109,16 +109,17 @@ void NaiveClient::OnRunComplete(int connection_id, int result) { void NaiveClient::HandleRunResult(NaiveClientConnection* connection, int result) { - LOG(INFO) << "Connection " << connection->id() - << " ended: " << ErrorToString(result); - Close(connection->id()); + Close(connection->id(), result); } -void NaiveClient::Close(int connection_id) { +void NaiveClient::Close(int connection_id, int reason) { auto it = connection_by_id_.find(connection_id); if (it == connection_by_id_.end()) return; + LOG(INFO) << "Connection " << connection_id + << " closed: " << ErrorToShortString(reason); + // The call stack might have callbacks which still have the pointer of // connection. Instead of referencing connection with ID all the time, // destroys the connection in next run loop to make sure any pending diff --git a/net/tools/naive/naive_client.h b/net/tools/naive/naive_client.h index 90ac49feb2..a65e5369cd 100644 --- a/net/tools/naive/naive_client.h +++ b/net/tools/naive/naive_client.h @@ -38,7 +38,7 @@ class NaiveClient { void OnRunComplete(int connection_id, int result); void HandleRunResult(NaiveClientConnection* connection, int result); - void Close(int connection_id); + void Close(int connection_id, int reason); NaiveClientConnection* FindConnection(int connection_id); bool HasClosedConnection(NaiveClientConnection* connection);