Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes in AcceptThread method #89

Merged
merged 5 commits into from
Apr 24, 2020
Merged

Fixes in AcceptThread method #89

merged 5 commits into from
Apr 24, 2020

Conversation

MateuszKlatecki
Copy link
Member

@MateuszKlatecki MateuszKlatecki commented Apr 23, 2020

Description

  1. Cleanup done with exceptions in the AcceptThreadFunc function.

Only the SocketException was caught, but it was possible to throw:

  • Socket throws: ObjectDisposedException
  • NetworkStream throws: System.IO.IOException, System.ArgumentNullException
  • SslStream throws: System.IO.IOException, System.ArgumentNullException, NotSupportedException
  1. Restoring incorrectly deleted retry variable increment in commit f3122ac

Motivation and Context

  • increase http server stability

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Signed-off-by: Mateusz Klatecki mateusz.klatecki@gc5.pl

NetworkStream throws:  System.IO.IOException, System.ArgumentNullException
SslStream throws: System.IO.IOException, System.ArgumentNullException, NotSupportedException

none of these exceptions are caught, nothing can throw the SocketException exception
@nfbot
Copy link
Member

nfbot commented Apr 23, 2020

Hi @MateuszKlatecki,

I'm nanoFramework bot.
Thank you for your contribution!

A human will be reviewing it shortly. 😉

@CLAassistant
Copy link

CLAassistant commented Apr 23, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

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

@MateuszKlatecki the SocketException is thrown in the native end. Removing this code block seems a bit harsh…

Agreed on the need to catch other exceptions.

As for retry var it was wrongly removed on this commit as part of a clean-up from Sonarcloud suggested improvements: f3122ac
So it should be put back where it was. Unless there is a good reason for dropping this 5 attempts strategy.
(which I'm not advocating it has to be there, just pointing out).

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

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

On a closer look, the error from SonarCloud doesn't look right... (and this is what caused that line to be removed). The retry var is being reset after a successful return from socket Accept() and their algorithm seems to be ignoring that, like if the fact that's inside a try catch necessarily means that the execution will go away.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@MateuszKlatecki
Copy link
Member Author

It seems that pre-incrementation has solved the problem

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

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

Nice workaround!
LGTM.

@josesimoes josesimoes changed the title Cleaning up the http server Fixes in AcceptThread method Apr 24, 2020
@josesimoes josesimoes merged commit ed4f3d9 into nanoframework:develop Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants