Skip to content

Commit b6ea794

Browse files
committed
Switch to using ref counts
1 parent baf1192 commit b6ea794

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

src/core/api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ MsQuicConnectionStart(
444444
goto Error;
445445
}
446446

447-
QuicConfigurationAddRef(Configuration, QUIC_CONF_REF_OPERATION);
447+
QuicConfigurationAddRef(Configuration, QUIC_CONF_REF_CONN_START_OP);
448448
Oper->API_CALL.Context->Type = QUIC_API_TYPE_CONN_START;
449449
Oper->API_CALL.Context->CONN_START.Configuration = Configuration;
450450
Oper->API_CALL.Context->CONN_START.ServerName = ServerNameCopy;
@@ -543,7 +543,7 @@ MsQuicConnectionSetConfiguration(
543543
goto Error;
544544
}
545545

546-
QuicConfigurationAddRef(Configuration, QUIC_CONF_REF_OPERATION);
546+
QuicConfigurationAddRef(Configuration, QUIC_CONF_REF_CONN_SET_OP);
547547
Oper->API_CALL.Context->Type = QUIC_API_TYPE_CONN_SET_CONFIGURATION;
548548
Oper->API_CALL.Context->CONN_SET_CONFIGURATION.Configuration = Configuration;
549549

src/core/configuration.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ MsQuicConfigurationOpen(
8585
Configuration->Registration = Registration;
8686
CxPlatRefInitialize(&Configuration->RefCount);
8787
#if DEBUG
88-
Configuration->RefTypeCount[QUIC_CONF_REF_HANDLE] = 1;
88+
CxPlatRefInitialize(&Configuration->RefTypeCount[QUIC_CONF_REF_HANDLE]);
8989
#endif
9090

9191
Configuration->AlpnListLength = (uint16_t)AlpnListLength;

src/core/configuration.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
66
--*/
77

8+
//
9+
// The different kinds of references on a Configuration.
10+
//
811
typedef enum QUIC_CONFIGURATION_REF {
912

10-
QUIC_CONF_REF_HANDLE, // The handle provided to the app.
11-
QUIC_CONF_REF_CONNECTION, // Per connection using this Configuration.
12-
QUIC_CONF_REF_LOAD_CRED, // During async credential loading.
13-
QUIC_CONF_REF_OPERATION, // Per queued operation.
13+
QUIC_CONF_REF_HANDLE,
14+
QUIC_CONF_REF_CONNECTION,
15+
QUIC_CONF_REF_LOAD_CRED,
16+
QUIC_CONF_REF_CONN_START_OP,
17+
QUIC_CONF_REF_CONN_SET_OP,
1418

1519
QUIC_CONF_REF_COUNT
1620
} QUIC_CONFIGURATION_REF;
@@ -45,7 +49,7 @@ typedef struct QUIC_CONFIGURATION {
4549
//
4650
// Detailed Reference count.
4751
//
48-
uint16_t RefTypeCount[QUIC_CONF_REF_COUNT];
52+
CXPLAT_REF_COUNT RefTypeCount[QUIC_CONF_REF_COUNT];
4953
#endif
5054

5155
//
@@ -127,12 +131,12 @@ QuicConfigurationAddRef(
127131
_In_ QUIC_CONFIGURATION_REF Ref
128132
)
129133
{
134+
CxPlatRefIncrement(&Configuration->RefCount);
130135
#if DEBUG
131-
InterlockedIncrement16((volatile short*)&Configuration->RefTypeCount[Ref]);
136+
CxPlatRefIncrement(&Configuration->RefTypeCount[Ref]);
132137
#else
133138
UNREFERENCED_PARAMETER(Ref);
134139
#endif
135-
CxPlatRefIncrement(&Configuration->RefCount);
136140
}
137141

138142
//
@@ -146,9 +150,7 @@ QuicConfigurationRelease(
146150
)
147151
{
148152
#if DEBUG
149-
CXPLAT_TEL_ASSERT(Configuration->RefTypeCount[Ref] > 0);
150-
uint16_t Result = (uint16_t)InterlockedDecrement16((volatile short*)&Configuration->RefTypeCount[Ref]);
151-
CXPLAT_TEL_ASSERT(Result != 0xFFFF);
153+
CxPlatRefDecrement(&Configuration->RefTypeCount[Ref]);
152154
#else
153155
UNREFERENCED_PARAMETER(Ref);
154156
#endif

src/core/operation.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ QuicOperationFree(
9595
if (Oper->Type == QUIC_OPER_TYPE_API_CALL) {
9696
QUIC_API_CONTEXT* ApiCtx = Oper->API_CALL.Context;
9797
if (ApiCtx->Type == QUIC_API_TYPE_CONN_START) {
98-
QuicConfigurationRelease(ApiCtx->CONN_START.Configuration, QUIC_CONF_REF_OPERATION);
98+
QuicConfigurationRelease(ApiCtx->CONN_START.Configuration, QUIC_CONF_REF_CONN_START_OP);
9999
if (ApiCtx->CONN_START.ServerName != NULL) {
100100
CXPLAT_FREE(ApiCtx->CONN_START.ServerName, QUIC_POOL_SERVERNAME);
101101
}
102102
} else if (ApiCtx->Type == QUIC_API_TYPE_CONN_SET_CONFIGURATION) {
103-
QuicConfigurationRelease(ApiCtx->CONN_SET_CONFIGURATION.Configuration, QUIC_CONF_REF_OPERATION);
103+
QuicConfigurationRelease(ApiCtx->CONN_SET_CONFIGURATION.Configuration, QUIC_CONF_REF_CONN_SET_OP);
104104
} else if (ApiCtx->Type == QUIC_API_TYPE_CONN_SEND_RESUMPTION_TICKET) {
105105
if (ApiCtx->CONN_SEND_RESUMPTION_TICKET.ResumptionAppData != NULL) {
106106
CXPLAT_DBG_ASSERT(ApiCtx->CONN_SEND_RESUMPTION_TICKET.AppDataLength != 0);

0 commit comments

Comments
 (0)