Skip to content

Commit

Permalink
fix some more
Browse files Browse the repository at this point in the history
  • Loading branch information
csujedihy committed Nov 30, 2023
1 parent d7eb036 commit a0fbb07
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/perf/lib/PerfClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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); }
}
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/perf/lib/Tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ TcpConnection::~TcpConnection()
}
CXPLAT_DBG_ASSERT(!QueuedOnWorker);
CxPlatDispatchLockUninitialize(&Lock);
++Uninit;
}

_IRQL_requires_max_(DISPATCH_LEVEL)
Expand Down
1 change: 1 addition & 0 deletions src/perf/lib/Tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit a0fbb07

Please sign in to comment.