Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: close listeners in registration rundown #3823

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/core/listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ MsQuicListenerOpen(
QuicSiloAddRef(Listener->Silo);
#endif

CxPlatDispatchLockAcquire(&Registration->ListenerLock);
CxPlatListInsertTail(&Registration->Listeners, &Listener->RegistrationLink);
qzhuyan marked this conversation as resolved.
Show resolved Hide resolved
CxPlatDispatchLockRelease(&Registration->ListenerLock);

BOOLEAN Result = CxPlatRundownAcquire(&Registration->Rundown);
CXPLAT_DBG_ASSERT(Result); UNREFERENCED_PARAMETER(Result);

Expand Down Expand Up @@ -117,6 +121,10 @@ QuicListenerFree(
QuicSiloRelease(Listener->Silo);
#endif

CxPlatDispatchLockAcquire(&Listener->Registration->ListenerLock);
CxPlatListEntryRemove(&Listener->RegistrationLink);
CxPlatDispatchLockRelease(&Listener->Registration->ListenerLock);

CxPlatRefUninitialize(&Listener->RefCount);
CxPlatEventUninitialize(Listener->StopEvent);
CXPLAT_DBG_ASSERT(Listener->AlpnList == NULL);
Expand Down
5 changes: 5 additions & 0 deletions src/core/listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ typedef struct QUIC_LISTENER {
//
QUIC_REGISTRATION* Registration;

//
// Link into the registrations's list of listeners.
//
CXPLAT_LIST_ENTRY RegistrationLink;

#ifdef QUIC_SILO
//
// The silo.
Expand Down
25 changes: 25 additions & 0 deletions src/core/registration.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ MsQuicRegistrationOpen(
CxPlatListInitializeHead(&Registration->Configurations);
CxPlatDispatchLockInitialize(&Registration->ConnectionLock);
CxPlatListInitializeHead(&Registration->Connections);
CxPlatDispatchLockInitialize(&Registration->ListenerLock);
CxPlatListInitializeHead(&Registration->Listeners);
CxPlatRundownInitialize(&Registration->Rundown);
Registration->AppNameLength = (uint8_t)(AppNameLength + 1);
if (AppNameLength != 0) {
Expand Down Expand Up @@ -247,6 +249,18 @@ MsQuicRegistrationShutdown(
Entry = Entry->Flink;
}

CxPlatDispatchLockAcquire(&Registration->ListenerLock);
nibanks marked this conversation as resolved.
Show resolved Hide resolved
Entry = Registration->Listeners.Flink;
while (Entry != &Registration->Listeners) {

QUIC_LISTENER* Listener =
CXPLAT_CONTAINING_RECORD(Entry, QUIC_LISTENER, RegistrationLink);

MsQuicListenerClose((void *)Listener);
qzhuyan marked this conversation as resolved.
Show resolved Hide resolved
Entry = Entry->Flink;
}
CxPlatDispatchLockRelease(&Registration->ListenerLock);

CxPlatDispatchLockRelease(&Registration->ConnectionLock);
}

Expand Down Expand Up @@ -291,6 +305,17 @@ QuicRegistrationTraceRundown(
}

CxPlatDispatchLockRelease(&Registration->ConnectionLock);

CxPlatDispatchLockAcquire(&Registration->ListenerLock);

for (CXPLAT_LIST_ENTRY* Link = Registration->Listeners.Flink;
Link != &Registration->Listeners;
Link = Link->Flink) {
QuicListenerTraceRundown(
CXPLAT_CONTAINING_RECORD(Link, QUIC_LISTENER, RegistrationLink));
}

CxPlatDispatchLockRelease(&Registration->ListenerLock);
}

_IRQL_requires_max_(PASSIVE_LEVEL)
Expand Down
10 changes: 10 additions & 0 deletions src/core/registration.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ typedef struct QUIC_REGISTRATION {
//
CXPLAT_LIST_ENTRY Connections;

//
// Protects access to the Listener list.
//
CXPLAT_LOCK ListenerLock;
qzhuyan marked this conversation as resolved.
Show resolved Hide resolved

//
// List of all Listeners for this registration.
//
CXPLAT_LIST_ENTRY Listeners;

//
// Rundown for all child objects.
//
Expand Down