Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@baulig
Copy link
Contributor

@baulig baulig commented Aug 14, 2019

No description provided.


try {
if (tunnel?.Data != null)
await sslStream.WriteAsync (tunnel.Data, 0, tunnel.Data.Length, cancellationToken).ConfigureAwait (false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this even going to work given that we set sslStream = null; on line 140 above?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm following it correctly, line 140 may not be hit. At the very least, we should make sure sslStream != null.

Copy link
Member

@akoeplinger akoeplinger Aug 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be hit if status != WebExceptionStatus.Success so unless that implies that tunnel?.Data is always null then we'll hit this (and if it does we should add a comment or the sslStream != null check to nake it clear) 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to say may not always be hit lol. I agree with you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code may look a little bit confusing - but sslStream can never be null after the first exception block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be hit if status != WebExceptionStatus.Success so unless that implies that tunnel?.Data is always null then we'll hit this (and if it does we should add a comment or the sslStream != null check to nake it clear) 😄

The last line of the try sets status = WebExceptionStatus.Success - the only way it can have any other value is from within the catch block - and that ends with a throw. So that sslStream = null on line 140 can only happen when we're re-throwing from within the catch block.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. I wonder if it would be clearer putting the two blocks into separate functions?

@steveisok
Copy link
Contributor

@monojenkins build failed

@akoeplinger akoeplinger merged commit a3c31b9 into mono:master Aug 19, 2019
@akoeplinger
Copy link
Member

How far back do we need to backport this?

@akoeplinger
Copy link
Member

Talked with Steve, back to 2019-06 is fine.

@monojenkins backport 2019-08
@monojenkins backport 2019-06

@baulig baulig deleted the work-sslstream-dispose branch August 19, 2019 16:13
akoeplinger pushed a commit that referenced this pull request Aug 20, 2019
…ateStream()`. (#16327)

* Add missing `Dispose()` call on error in `MonoTlsStream.CreateStream()`.

* Remove the `finally` block to make it more easy to read.

Backport of #16233.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants