Skip to content

QUIC: Should not need finalization on MsQuicStream/Connection/Listener #55103

@geoffkizer

Description

@geoffkizer

Currently we have a chain of objects for each of Stream/Connection/Listener that looks like this:

MsQuicStream (finalizable) -> stream State object (rooted by GCHandle) -> SafeMsQuicStreamHandle (finalizable)

We shouldn't need MsQuicStream to be finalizable; we should be able to rely on the SafeHandle finalizer -- after all that's what it is for.

The reason we need this today is that msquic holds a GCHandle to the State object, which roots it until the msquic stream handle is closed and all events are processed. But the State object holds a ref to the SafeHandle, which means the SafeHandle itself will never be finalized. We use the finalizer on MsQuicStream to break this loop.

I think we can solve this by removing the reference from State to the SafeHandle. In general we shouldn't need this; the MsQuicStream can pass the handle into appropriate methods on State when necessary.

So:

MsQuicStream -> stream State object (rooted by GCHandle)
MsQuicStream -> SafeMsQuicStreamHandle (finalizable)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Net.QuicenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions