Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 0 additions & 6 deletions src/core/listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
#include "listener.c.clog.h"
#endif

_IRQL_requires_max_(PASSIVE_LEVEL)
void
QuicListenerStopAsync(
_In_ QUIC_LISTENER* Listener
);

BOOLEAN
QuicListenerIsOnWorker(
_In_ QUIC_LISTENER* Listener
Expand Down
9 changes: 9 additions & 0 deletions src/core/listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,12 @@ BOOLEAN
QuicListenerDrainOperations(
_In_ QUIC_LISTENER* Listener
);

//
// Stops the listener asynchronously.
//
_IRQL_requires_max_(PASSIVE_LEVEL)
void
QuicListenerStopAsync(
_In_ QUIC_LISTENER* Listener
);
32 changes: 27 additions & 5 deletions src/core/registration.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,36 @@ MsQuicRegistrationShutdown(
Entry = Entry->Flink;
}

CxPlatDispatchLockRelease(&Registration->ConnectionLock);
//
// Prevent close/shutdown races: once we drop the registration lock we must not
// depend on the shared listener list or listener lifetime. We snapshot listeners
// under lock and take a non-zero ref so only still-alive listeners are handled
// afterward.
//
CXPLAT_LIST_ENTRY PendingListeners;
CxPlatListInitializeHead(&PendingListeners);

Entry = Registration->Listeners.Flink;
while (Entry != &Registration->Listeners) {
while (!CxPlatListIsEmpty(&Registration->Listeners)) {
Entry = CxPlatListRemoveHead(&Registration->Listeners);
QUIC_LISTENER* Listener =
CXPLAT_CONTAINING_RECORD(Entry, QUIC_LISTENER, RegistrationLink);
Entry = Entry->Flink;
MsQuicListenerStop((HQUIC)Listener);

if (CxPlatRefIncrementNonZero(&Listener->RefCount, 1)) {
CxPlatListInsertTail(&PendingListeners, &Listener->RegistrationLink);
}
}

CxPlatDispatchLockRelease(&Registration->ConnectionLock);

while (!CxPlatListIsEmpty(&PendingListeners)) {
QUIC_LISTENER* Listener =
CXPLAT_CONTAINING_RECORD(
CxPlatListRemoveHead(&PendingListeners),
QUIC_LISTENER,
RegistrationLink);

QuicListenerStopAsync(Listener);
QuicListenerRelease(Listener);
}
}

Expand Down
Loading