diff --git a/fdbrpc/FlowTransport.actor.cpp b/fdbrpc/FlowTransport.actor.cpp index 1fd5ede75a..b47c5527ec 100644 --- a/fdbrpc/FlowTransport.actor.cpp +++ b/fdbrpc/FlowTransport.actor.cpp @@ -381,7 +381,16 @@ struct Peer : NonCopyable { self->outgoingConnectionIdle = false; } - Void _ = wait( connectionWriter( self, conn ) || reader || connectionMonitor(self) ); + try { + self->transport->countConnEstablished++; + Void _ = wait( connectionWriter( self, conn ) || reader || connectionMonitor(self) ); + } catch (Error& e) { + if (e.code() == error_code_connection_failed || e.code() == error_code_actor_cancelled || ( g_network->isSimulated() && e.code() == error_code_checksum_failed )) + self->transport->countConnClosedWithoutError++; + else + self->transport->countConnClosedWithError++; + throw e; + } ASSERT( false ); } catch (Error& e) { @@ -396,10 +405,6 @@ struct Peer : NonCopyable { if(self->compatible) { TraceEvent(ok ? SevInfo : SevError, "ConnectionClosed", conn ? conn->getDebugID() : UID()).detail("PeerAddr", self->destination).error(e, true); - if (ok) - self->transport->countConnClosedWithoutError++; - else - self->transport->countConnClosedWithError++; } else { TraceEvent(ok ? SevInfo : SevError, "IncompatibleConnectionClosed", conn ? conn->getDebugID() : UID()).detail("PeerAddr", self->destination).error(e, true); @@ -626,8 +631,6 @@ ACTOR static Future connectionReader( TraceEvent("ConnectionEstablished", conn->getDebugID()) .detail("Peer", conn->getPeerAddress()) .detail("ConnectionId", connectionId); - - transport->countConnEstablished++; } if(connectionId > 1) {