Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/core/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ QuicConnAlloc(

Connection->RefCount = 1;
#if DEBUG
Connection->RefTypeCount[QUIC_CONN_REF_HANDLE_OWNER] = 1;
CxPlatRefInitializeMultiple(Connection->RefTypeBiasedCount, QUIC_CONN_REF_COUNT);
CxPlatRefIncrement(&Connection->RefTypeBiasedCount[QUIC_CONN_REF_HANDLE_OWNER]);
#endif
Connection->PartitionID = PartitionId;
Connection->State.Allocated = TRUE;
Expand Down
27 changes: 14 additions & 13 deletions src/core/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,10 @@ typedef struct QUIC_CONNECTION {
#if DEBUG
//
// Detailed ref counts
// Note: These ref counts are biased by 1, so lowest they go is 1. It is an
// error for them to ever be zero.
//
short RefTypeCount[QUIC_CONN_REF_COUNT];
CXPLAT_REF_COUNT RefTypeBiasedCount[QUIC_CONN_REF_COUNT];
#endif

//
Expand Down Expand Up @@ -1081,12 +1083,13 @@ QuicConnAddRef(
QuicConnValidate(Connection);

#if DEBUG
InterlockedIncrement16((volatile short*)&Connection->RefTypeCount[Ref]);
CxPlatRefIncrement(&Connection->RefTypeBiasedCount[Ref]);
#else
UNREFERENCED_PARAMETER(Ref);
#endif

InterlockedIncrement((volatile long*)&Connection->RefCount);
CXPLAT_FRE_ASSERT(Connection->RefCount < INT32_MAX);
InterlockedIncrement(&Connection->RefCount);
}

//
Expand All @@ -1106,20 +1109,13 @@ QuicConnRelease(
QuicConnValidate(Connection);

#if DEBUG
CXPLAT_TEL_ASSERT(Connection->RefTypeCount[Ref] > 0);
uint16_t result = (uint16_t)InterlockedDecrement16((volatile short*)&Connection->RefTypeCount[Ref]);
CXPLAT_TEL_ASSERT(result != UINT16_MAX);
CXPLAT_TEL_ASSERT(!CxPlatRefDecrement(&Connection->RefTypeBiasedCount[Ref]));
#else
UNREFERENCED_PARAMETER(Ref);
#endif

CXPLAT_DBG_ASSERT(Connection->RefCount > 0);
if (InterlockedDecrement((volatile long*)&Connection->RefCount) == 0) {
#if DEBUG
for (uint32_t i = 0; i < QUIC_CONN_REF_COUNT; i++) {
CXPLAT_TEL_ASSERT(Connection->RefTypeCount[i] == 0);
}
#endif
CXPLAT_FRE_ASSERT(Connection->RefCount > 0);
if (InterlockedDecrement(&Connection->RefCount) == 0) {
if (Ref == QUIC_CONN_REF_LOOKUP_RESULT) {
//
// Lookup results cannot be the last ref, as they can result in the
Expand All @@ -1129,6 +1125,11 @@ QuicConnRelease(
CXPLAT_DBG_ASSERT(Connection->Worker != NULL);
QuicWorkerQueueConnection(Connection->Worker, Connection);
} else {
#if DEBUG
for (uint32_t i = 0; i < QUIC_CONN_REF_COUNT; i++) {
CXPLAT_DBG_ASSERT(Connection->RefTypeBiasedCount[i] == 1);
}
#endif
QuicConnFree(Connection);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/inc/msquic_winkernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <ntstatus.h>
#include <basetsd.h>
#include <netioddk.h>
#include <ntintsafe.h>

#define QUIC_INLINE inline

Expand Down
1 change: 1 addition & 0 deletions src/plugins/dbg/quictypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ typedef union QUIC_CONNECTION_STATE {
BOOLEAN HandleClosed : 1; // Handle closed by application layer.
BOOLEAN Freed : 1; // Freed. Used for Debugging.
BOOLEAN Partitioned : 1; // The connection cannot move across partitions.
BOOLEAN CloseAsync : 1; // The connection will close without waiting for callbacks.

//
// Indicates whether packet number encryption is enabled or not for the
Expand Down
Loading