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

Fix socket timeout for sending & receiving #1753

Merged
merged 2 commits into from
Oct 30, 2020
Merged

Fix socket timeout for sending & receiving #1753

merged 2 commits into from
Oct 30, 2020

Conversation

MateuszKlatecki
Copy link
Member

@MateuszKlatecki MateuszKlatecki commented Oct 29, 2020

Description

Set proper timeout value

Motivation and Context

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)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)

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.

@nfbot
Copy link
Member

nfbot commented Oct 29, 2020

Hi @MateuszKlatecki,

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

A human will be reviewing it shortly. 😉

@nfbot
Copy link
Member

nfbot commented Oct 29, 2020

Hi @MateuszKlatecki,

😞 All our issues are tracked in Home repo. If this PR addresses an issue, make sure the reference to it follows the correct pattern: nanoFramework/Home#NNNN.

@nfbot
Copy link
Member

nfbot commented Oct 29, 2020

Hi @MateuszKlatecki,

😞 All our issues are tracked in Home repo. If this PR addresses an issue, make sure the reference to it follows the correct pattern: nanoFramework/Home#NNNN.

@dnfadmin
Copy link

dnfadmin commented Oct 29, 2020

CLA assistant check
All CLA requirements met.

@@ -661,6 +661,7 @@ HRESULT Library_sys_net_native_System_Net_Sockets_NativeSocket::SendRecvHelper(
CLR_UINT32 offset = stack.Arg2().NumericByRef().u4;
CLR_UINT32 count = stack.Arg3().NumericByRef().u4;
CLR_INT32 flags = stack.Arg4().NumericByRef().s4;
CLR_INT64 sendRecvTimeout = stack.Arg5().NumericByRef().s4;
Copy link
Member

Choose a reason for hiding this comment

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

Let's call this just timeout, for simplicity.

Copy link
Member Author

Choose a reason for hiding this comment

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

The timeout variable is already declared in this function to something else.
Since the condition below is not needed, as you can see, this value is only used once, so I won't create a temporary variable.

Copy link
Member

Choose a reason for hiding this comment

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

That's OK too. That's used mostly for debugging purposes. When building with optimisations the compiler would do that anyway.

}
else
{
hbTimeout.SetInteger(sendRecvTimeout * TIME_CONVERSION__TO_MILLISECONDS);
Copy link
Member

Choose a reason for hiding this comment

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

It's OK to call this one directly. No need to check for == -1.
The C# guarantees that this will be either -1 or whatever the user has set it.
When setting the value for the timer this is properly checked so no worries here.

Copy link
Member Author

Choose a reason for hiding this comment

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

You rightly noticed. In CLR_RT_ExecutionEngine :: InitTimeout there is already logic that will take care of the correct value.

@josesimoes josesimoes added Area: Common libs Everything related with common libraries and removed Status: under review ⚠️ DO NOT MERGE ⚠️ labels Oct 30, 2020
@josesimoes josesimoes changed the title Set proper timeout when sending/receiving data through network Fix socket timeout for sending & receiving Oct 30, 2020
@josesimoes josesimoes merged commit 50866c9 into nanoframework:develop Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Common libs Everything related with common libraries hacktoberfest-accepted Type: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timeouts do not work in network sockets
4 participants