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);