Skip to content

Commit 75b725c

Browse files
committed
make connection async close wait opt-in
1 parent 0da50a0 commit 75b725c

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/core/api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ MsQuicConnectionClose(
217217
if (MsQuicLib.CustomExecutions) {
218218
//
219219
// For custom executions, ConnectionClose completes asynchronously.
220+
// Review: should this be opt-in behavior?
220221
//
221222
Connection->CloseApiContext.Completed = NULL;
222223
WaitForCompletion = FALSE;

src/inc/msquic.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ struct MsQuicConnection {
11491149
QUIC_UINT62 AppShutdownErrorCode {0};
11501150
bool HandshakeComplete {false};
11511151
bool HandshakeResumed {false};
1152-
bool Started {false};
1152+
bool AsyncClose {false};
11531153
uint32_t ResumptionTicketLength {0};
11541154
uint8_t* ResumptionTicket {nullptr};
11551155
#ifdef CX_PLATFORM_TYPE
@@ -1217,7 +1217,7 @@ struct MsQuicConnection {
12171217
~MsQuicConnection() noexcept {
12181218
Close();
12191219
#ifdef CX_PLATFORM_TYPE
1220-
if (IsValid()) {
1220+
if (AsyncClose) {
12211221
ShutdownCompleteEvent.WaitForever();
12221222
}
12231223
#endif // CX_PLATFORM_TYPE
@@ -1263,11 +1263,7 @@ struct MsQuicConnection {
12631263
const char* ServerName,
12641264
_In_ uint16_t ServerPort // Host byte order
12651265
) noexcept {
1266-
QUIC_STATUS Status = MsQuic->ConnectionStart(Handle, Config, Family, ServerName, ServerPort);
1267-
if (QUIC_SUCCEEDED(Status)) {
1268-
Started = true;
1269-
}
1270-
return Status;
1266+
return MsQuic->ConnectionStart(Handle, Config, Family, ServerName, ServerPort);
12711267
}
12721268

12731269
QUIC_STATUS

src/test/lib/ApiTest.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6989,7 +6989,9 @@ QuicTestValidatePartitionInline(const uint32_t EcCount)
69896989
// The registration close will not complete until each of these objects is
69906990
// cleaned up, so we do not need to wait for each of these explicitly.
69916991
//
6992+
Server->AsyncClose = TRUE;
69926993
Server->Close();
6994+
Server->AsyncClose = TRUE;
69936995
Client->Close();
69946996
Listener.Stop();
69956997

@@ -7124,6 +7126,13 @@ QuicTestValidatePartitionWorker(const uint32_t EcCount)
71247126
return QUIC_STATUS_CONTINUE;
71257127
})
71267128
);
7129+
7130+
//
7131+
// Ensure the connections wait for the final shutdown callback before
7132+
// finishing destruction.
7133+
//
7134+
Server->AsyncClose = TRUE;
7135+
Client.AsyncClose = TRUE;
71277136
}
71287137

71297138
for (uint32_t i = 0; i < EcCount; i++) {

0 commit comments

Comments
 (0)