Skip to content

Commit 65eaf6e

Browse files
committed
The CxPlatRef* routines expect a CXPLAT_REF_COUNT to always have at least 1 ref count. Use plain increment/decrement
1 parent e3f0940 commit 65eaf6e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/core/registration.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ QuicRegistrationRundownAcquire(
183183
//
184184
// Only increment the detailed ref count if the Rundown acquire succeeded.
185185
//
186-
CxPlatRefIncrement(&Registration->RefTypeCount[Ref]);
186+
InterlockedIncrement64(&Registration->RefTypeCount[Ref]);
187187
}
188188
#else
189189
UNREFERENCED_PARAMETER(Ref);
@@ -204,7 +204,8 @@ QuicRegistrationRundownRelease(
204204
)
205205
{
206206
#if DEBUG
207-
CxPlatRefDecrement(&Registration->RefTypeCount[Ref]);
207+
InterlockedDecrement64(&Registration->RefTypeCount[Ref]);
208+
CXPLAT_DBG_ASSERT(QuicReadLongPtrNoFence(&Registration->RefTypeCount[Ref]) >= 0);
208209
#else
209210
UNREFERENCED_PARAMETER(Ref);
210211
#endif

src/inc/quic_platform_posix.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@ InterlockedDecrement64(
291291
return __sync_sub_and_fetch(Addend, (int64_t)1);
292292
}
293293

294-
#define QuicReadPtrNoFence(p) ((void*)(*p)) // TODO
294+
#define QuicReadPtrNoFence(p) __atomic_load_n((p), __ATOMIC_RELAXED)
295+
296+
#define QuicReadLongPtrNoFence(p) __atomic_load_n((p), __ATOMIC_RELAXED)
295297

296298
//
297299
// Assertion interfaces.

0 commit comments

Comments
 (0)