Repository navigation
Fix lock during SslStream renegotiation request - #56470
Conversation
|
Tagging subscribers to this area: @dotnet/ncl, @vcsjones Issue DetailsWhen server request renegotiation on client stream with pending data, the server trow exception as expected but lock is not released. This PR fix this behaviour and extend related test to cover this case. Close #56345
|
There was a problem hiding this comment.
Are we allowed to read _decryptedBytesCount when we don't hold the locks?
Rather than moving this earlier, should it instead be moved down into the try?
There was a problem hiding this comment.
Putting it down would be safer. We try to prevent people from using this concurrently with IO so it should not be valid case but since it is easy I think it is ok to do little bit more work e.g. do the increments/decrements.
There was a problem hiding this comment.
moved to the try block
0e899aa to
2f3f500
Compare
| _nestedWrite = 0; | ||
| _isRenego = false; | ||
| // We will not release _nestedAuth at this point to prevent another renegotiation attempt. | ||
| _nestedAuth = 0; |
There was a problem hiding this comment.
The renegotiation should be done we don't need postpone clear this lock
| } | ||
| if (_decryptedBytesCount is not 0) | ||
| { | ||
| _nestedAuth = 0; |
There was a problem hiding this comment.
I don't think we should clear it here. This was purposely left set in the finally so the RenegotiateAsync can be called at most once.
I think especially if we throw the rest would be unpredictable IMHO.
Also if we throw for _nestedRead or _nestedWrite this would still be set. I think that is ok as the intention is not to allow multiple calls but it would be inconsistent.
There was a problem hiding this comment.
You are right, I was tempted by wrong change in test.
|
iOSSimulator and tvOSSimulator tests are hanging, however this change is not for those platforms. Merging. |
When server request renegotiation on client stream with pending data, the server trow exception as expected but lock is not released.
This PR fix this behaviour and extend related test to cover this case.
Close #56345