Skip to content

Conversation

@pfalcon
Copy link
Contributor

@pfalcon pfalcon commented Apr 20, 2019

Previously, a case when poll() call timed out wasn't handled, and
recv() was called unconditionally. In the case of timeout, recv()
itself would hang indefinitely.

Signed-off-by: Paul Sokolovsky [email protected]

@pfalcon pfalcon requested review from d3zd3z, galak and jukkar April 20, 2019 18:48
@pfalcon pfalcon force-pushed the sntp-fixes branch 2 times, most recently from 634069a to fd6bac5 Compare April 20, 2019 19:00
@pfalcon
Copy link
Contributor Author

pfalcon commented Apr 20, 2019

@galak, Getting SNTP into a workable state is on critical path to get Google IoT SDK working, please help to review/merge this.

@pfalcon pfalcon changed the title net: sntp: Handle case of request timeout net: sntp: Handle case of request timeout and fix up sample Apr 20, 2019
Copy link
Member

@jukkar jukkar left a comment

Choose a reason for hiding this comment

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

Minor nit pick, looks ok otherwise.

Copy link
Member

Choose a reason for hiding this comment

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

For timeout, better use K_SECONDS(4) instead, preferably via a define.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used K_SECONDS(4). As these are supposed to be learning samples, using too much defines would only make them more complicated to follow (and yes, there're different delays, e.g. IPv4 case vs IPv6 case one; better just to have them inline).

Copy link
Member

Choose a reason for hiding this comment

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

As these are supposed to be learning samples, using too much defines would only make them more complicated to follow

I am disagreeing here. For the novice user reading the code, it is much easier if the parameter says SNTP_TIMEOUT than K_SECONDS(4). Not a big issue thou, it is still better now than before.

Copy link
Contributor

@d3zd3z d3zd3z left a comment

Choose a reason for hiding this comment

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

The fix seems good. I'm not sure if the config file and logging changes should be in the same commit.

Copy link
Member

Choose a reason for hiding this comment

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

I think you have a typo here. Should be SNTP IPv6 right?

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, that is a good catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be SNTP IPv6 right?

Fixed, thanks.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, that is a good catch.

pfalcon added 2 commits April 24, 2019 11:22
Previously, a case when poll() call timed out wasn't handled, and
recv() was called unconditionally. In the case of timeout, recv()
itself would hang indefinitely.

Signed-off-by: Paul Sokolovsky <[email protected]>
1. Output what steps the app performs, so it doesn't look to user
that it simply hanged.
2. Don't use infinite timeouts, because that will hang.
3. Clearly note which requests are for IPv4 vs IPv6 server.
4. Define IPv4 gateway. This sample is configured to run against
SNTP on local Linux host, but standard distros (e.g. Ubuntu) don't
run SNTP server by default, so usual outcome for running this sample
will be timeout. A realistic way to get successful output would be
to run it against a server on the Internet, for what a gateway is
required.

Signed-off-by: Paul Sokolovsky <[email protected]>
@pfalcon
Copy link
Contributor Author

pfalcon commented Apr 24, 2019

@jukkar: The issue resolved, CI passed.

@jukkar jukkar merged commit 901d85b into zephyrproject-rtos:master Apr 24, 2019
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