Repository navigation
|
I don't really understand the locking used in the reference client's
In Is there some reason this cannot happen in practice? |
Replies: 1 comment
|
You are right, it can happen. The In practice the window is small: the handler only swaps to a new session after reactivating the old one failed, so calls on the old session fail anyway at that point (
In 2.0 the recommended way avoids the swap entirely: Closing as answered. A PR that makes the sample's session access safer is welcome. |
You are right, it can happen. The
lockinClient_ReconnectCompleteonly makes the swap itself consistent with the keep-alive handler. Code inClientSamples/Programthat readsuaClient.Sessionwithout synchronization can still hold the old reference while it is disposed. The sample keeps it simple on purpose and does not show a production-grade pattern.In practice the window is small: the handler only swaps to a new session after reactivating the old one failed, so calls on the old session fail anyway at that point (
BadSessionClosed,BadNotConnected,BadSecureChannelClosed, orObjectDisposedExceptionif it is already disposed). With a rawSessionplusSessionReconnectHandler, the applicat…