@@ -220,7 +220,12 @@ typedef struct QUIC_STREAM {
220220 CXPLAT_REF_COUNT RefCount ;
221221
222222#if DEBUG
223- short RefTypeCount [QUIC_STREAM_REF_COUNT ];
223+ //
224+ // Detailed ref counts.
225+ // Note: These ref counts are biased by 1, so lowest they go is 1. It is an
226+ // error for them to ever be zero.
227+ //
228+ CXPLAT_REF_COUNT RefTypeBiasCount [QUIC_STREAM_REF_COUNT ];
224229#endif
225230
226231 //
@@ -707,7 +712,7 @@ QuicStreamAddRef(
707712 CXPLAT_DBG_ASSERT (Stream -> RefCount > 0 );
708713
709714#if DEBUG
710- InterlockedIncrement16 (( volatile short * ) & Stream -> RefTypeCount [Ref ]);
715+ CxPlatRefIncrement ( & Stream -> RefTypeBiasCount [Ref ]);
711716#else
712717 UNREFERENCED_PARAMETER (Ref );
713718#endif
@@ -732,17 +737,15 @@ QuicStreamRelease(
732737 CXPLAT_TEL_ASSERT (Stream -> RefCount > 0 );
733738
734739#if DEBUG
735- CXPLAT_TEL_ASSERT (Stream -> RefTypeCount [Ref ] > 0 );
736- uint16_t result = (uint16_t )InterlockedDecrement16 ((volatile short * )& Stream -> RefTypeCount [Ref ]);
737- CXPLAT_TEL_ASSERT (result != 0xFFFF );
740+ CXPLAT_TEL_ASSERT (!CxPlatRefDecrement (& Stream -> RefTypeBiasCount [Ref ]));
738741#else
739742 UNREFERENCED_PARAMETER (Ref );
740743#endif
741744
742745 if (CxPlatRefDecrement (& Stream -> RefCount )) {
743746#if DEBUG
744747 for (uint32_t i = 0 ; i < QUIC_STREAM_REF_COUNT ; i ++ ) {
745- CXPLAT_TEL_ASSERT (Stream -> RefTypeCount [i ] == 0 );
748+ CXPLAT_TEL_ASSERT (Stream -> RefTypeBiasCount [i ] == 1 );
746749 }
747750#endif
748751 QuicStreamFree (Stream );
0 commit comments