diff --git a/src/perf/lib/PerfClient.cpp b/src/perf/lib/PerfClient.cpp index a902ce54c1..227d7ab322 100644 --- a/src/perf/lib/PerfClient.cpp +++ b/src/perf/lib/PerfClient.cpp @@ -439,7 +439,17 @@ PerfClientWorker::WorkerThread() { auto Connection = (PerfClientConnection*)CxPlatListRemoveHead(&ConnectionTable); Connection->TcpConn->Close(); // TODO - Any race conditions here? Connection->TcpConn = nullptr; - ConnectionPool.Free(Connection); + CXPLAT_HASHTABLE_ENUMERATOR Enum; + Connection->StreamTable.EnumBegin(&Enum); + for (;;) { + auto Stream = (PerfClientStream*)Connection->StreamTable.EnumNext(&Enum); + if (Stream == NULL) { + break; + } + Connection->StreamTable.Remove(&Stream->Entry); + StreamPool.Free(Stream); + } + Connection->StreamTable.EnumEnd(&Enum); } Lock.Release(); } @@ -467,7 +477,7 @@ PerfClientWorker::StartNewConnection() { PerfClientConnection::~PerfClientConnection() { if (Client.UseTCP) { - if (TcpConn) { TcpConn->Close(); } // TODO - Free to pool instead + if (TcpConn) { TcpConn->Close(); TcpConn = nullptr; } // TODO - Free to pool instead } else { if (Handle) { MsQuic->ConnectionClose(Handle); } } @@ -480,8 +490,8 @@ PerfClientConnection::Initialize() { CxPlatListInsertTail(&Worker.ConnectionTable, &Entry); Worker.Lock.Release(); auto CredConfig = MsQuicCredentialConfig(QUIC_CREDENTIAL_FLAG_CLIENT | QUIC_CREDENTIAL_FLAG_NO_CERTIFICATE_VALIDATION); - TcpConn = - Worker.TcpConnectionPool.Alloc( + TcpConn = // TODO: replace new/delete with pool alloc/free + new TcpConnection( Client.Engine, &CredConfig, Client.TargetFamily, diff --git a/src/perf/lib/Tcp.cpp b/src/perf/lib/Tcp.cpp index a87255eba8..5e2714da2d 100644 --- a/src/perf/lib/Tcp.cpp +++ b/src/perf/lib/Tcp.cpp @@ -403,6 +403,7 @@ TcpConnection::~TcpConnection() } CXPLAT_DBG_ASSERT(!QueuedOnWorker); CxPlatDispatchLockUninitialize(&Lock); + ++Uninit; } _IRQL_requires_max_(DISPATCH_LEVEL) diff --git a/src/perf/lib/Tcp.h b/src/perf/lib/Tcp.h index 4fe9391422..28b232884c 100644 --- a/src/perf/lib/Tcp.h +++ b/src/perf/lib/Tcp.h @@ -171,6 +171,7 @@ class TcpConnection { bool IndicateAccept{false}; bool IndicateConnect{false}; bool IndicateSendComplete{false}; + int16_t Uninit{0}; TcpConnection* Next{nullptr}; TcpEngine* Engine; TcpWorker* Worker{nullptr};