Skip to content

Commit

Permalink
Streams Hold References on Connections (#3931)
Browse files Browse the repository at this point in the history
  • Loading branch information
nibanks authored Oct 24, 2023
1 parent d65bb1a commit 102a491
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/core/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/core/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions src/core/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -209,6 +211,8 @@ QuicStreamFree(
Stream);
#pragma warning(pop)
}

QuicConnRelease(Connection, QUIC_CONN_REF_STREAM);
}

_IRQL_requires_max_(PASSIVE_LEVEL)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 102a491

Please sign in to comment.