From f8ad5d1dd6ee96cd06f9d0af240deee0c8e43dd9 Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Thu, 19 Oct 2023 14:39:56 -0400 Subject: [PATCH 1/2] Streams Hold References on Connections --- src/core/connection.h | 1 + src/core/stream.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/connection.h b/src/core/connection.h index 977e70cdb4..3eae03252b 100644 --- a/src/core/connection.h +++ b/src/core/connection.h @@ -224,6 +224,7 @@ typedef enum QUIC_CONNECTION_REF { QUIC_CONN_REF_LOOKUP_RESULT, // For connections returned from lookups. QUIC_CONN_REF_WORKER, // Worker is (queued for) processing. QUIC_CONN_REF_ROUTE, // Route resolution is undergoing. + QUIC_CONN_REF_STREAM, // A stream depends on the connection. QUIC_CONN_REF_COUNT diff --git a/src/core/stream.c b/src/core/stream.c index 7183a9626a..5f58c9309c 100644 --- a/src/core/stream.c +++ b/src/core/stream.c @@ -128,6 +128,8 @@ QuicStreamInitialize( Stream->MaxAllowedRecvOffset = Stream->RecvBuffer.VirtualBufferLength; Stream->RecvWindowLastUpdate = CxPlatTimeUs64(); + QuicConnAddRef(Connection, QUIC_CONN_REF_STREAM); + Stream->Flags.Initialized = TRUE; *NewStream = Stream; Stream = NULL; @@ -209,6 +211,8 @@ QuicStreamFree( Stream); #pragma warning(pop) } + + QuicConnRelease(Connection, QUIC_CONN_REF_STREAM); } _IRQL_requires_max_(PASSIVE_LEVEL) @@ -929,8 +933,8 @@ QuicStreamParamGet( if (!Stream->Flags.RemoteCloseResetReliable) { Status = QUIC_STATUS_INVALID_STATE; break; - } - + } + *(uint64_t*)Buffer = Stream->RecvMaxLength; Status = QUIC_STATUS_SUCCESS; break; From 2034f034bd6e17ec0ff662027d791eff51086559 Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Mon, 23 Oct 2023 13:22:45 -0400 Subject: [PATCH 2/2] Clean up some stream refs on uninitialize --- src/core/connection.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/connection.c b/src/core/connection.c index 96f8ec7b70..ef99c77502 100644 --- a/src/core/connection.c +++ b/src/core/connection.c @@ -503,6 +503,8 @@ QuicConnUninitialize( QuicCryptoUninitialize(&Connection->Crypto); QuicTimerWheelRemoveConnection(&Connection->Worker->TimerWheel, Connection); QuicOperationQueueClear(Connection->Worker, &Connection->OperQ); + QuicLossDetectionUninitialize(&Connection->LossDetection); + QuicSendUninitialize(&Connection->Send); if (Connection->CloseReasonPhrase != NULL) { CXPLAT_FREE(Connection->CloseReasonPhrase, QUIC_POOL_CLOSE_REASON); @@ -5318,7 +5320,7 @@ QuicConnRecvFrames( case QUIC_FRAME_IMMEDIATE_ACK: // Always accept the frame, because we always enable support. AckImmediately = TRUE; break; - + case QUIC_FRAME_TIMESTAMP: { // Always accept the frame, because we always enable support. if (!Connection->State.TimestampRecvNegotiated) { QuicTraceEvent( @@ -5345,7 +5347,7 @@ QuicConnRecvFrames( Packet->SendTimestamp = Frame.Timestamp; break; } - + default: // // No default case necessary, as we have already validated the frame