-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
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)