-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sock: change "no timeout" value from 0 to UINT32_MAX #5929
Conversation
I must confess to know next to nothing about |
What does 0 then do? |
|
I.e. return immediately - in any case. |
I should read more... Nevertheless, I still don't think it's a good idea. |
I wouldn't know how to implement such a case with stacks where |
* @ref sys_xtimer module is not present or the | ||
* implementation does not support timeouts on its own. | ||
* May be 0 for no timeout. | ||
* If 0 and no data is available, return immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean "the operation is non-blocking"? "return immediately" sounds more like implementation-speak...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, better. I'll change if you approve the change in general. (edit before here was a reply to another comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, better
Then this is null and void:
I wouldn't know how to implement such a case with stacks where 0 means no timeout... I would set it to one, maybe...
Then please add the return value -EWOULDBLOCK
or -EAGAIN
.
I'll change if you approve the change in general.
I still see some implementation confusions, but I guess that is the reviewers job to spot these ;-)
If you read the parameter as "how much time to wait at most until data arrives", "0" meaning "don't wait at all" is quite natural, don't you think?
You might save one instruction... |
Just add |
Marginally related: do you remember, why we decided against a configurable timeout for |
Actually, no, don't even remember discussing it. Seems to be missing. |
I have a slither of a memory, that Simon brought it up... |
Actually "the operation is non-blocking" seems less clear to me than "returns immediately". Would that extra s for return change your mind, too? |
Yes. |
* value `> 0`. If an error occurs on receive we just ignore it and continue | ||
* looping. | ||
* value `!= SOCK_NO_TIMEOUT`. If an error occurs on receive we just ignore it | ||
* and continue looping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder to self: fix this for #5923.
@miri64 I think I got all your comments? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last wording issue. Other then that I'm fine with this PR.
* @ref sys_xtimer module is not present or the | ||
* implementation does not support timeouts on its own. | ||
* May be 0 for no timeout. | ||
* If 0 and no data is available, returns immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, now I'm seeing this I immediately wonder: "What returns immediately" (the half-sentence is missing a subject ;-)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so "the function returns immediately." ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
* @ref sys_xtimer module is not present and the | ||
* implementation does not support timeouts on its own. | ||
* May be 0 for no timeout. | ||
* If 0 and no data is available, returns immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dito
* @ref sys_xtimer module is not present or the | ||
* implementation does not support timeouts on its own. | ||
* May be 0 for no timeout. | ||
* If 0 and no data is available, returns immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dito
* alternatively set the `timeout` parameter of @ref sock_udp_recv() to a | ||
* value `> 0`. If an error occurs on receive we just ignore it and continue | ||
* looping. | ||
* The application then waits indefinitely for an incoming message in `buf` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor question: Why did you change the line wrapping here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually leave the line wrapping to vim. Mark the paragraph, press "gq", good.
* looping. | ||
* The application then waits indefinitely for an incoming message in `buf` | ||
* from `remote`. If we want to timeout this wait period we could alternatively | ||
* set the `timeout` parameter of @ref sock_udp_recv() to a value != @ref |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the @ref
and SOCK_NO_TIMEOUT
to be on the same line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but together with the line change above the line would cross the 80 characters mark...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could put the line change before the @ref
or even the value !=
;-)
@@ -407,6 +407,7 @@ int sock_ip_get_remote(sock_ip_t *sock, sock_ip_ep_t *ep); | |||
* @return -EPROTO, if source address of received packet did not equal | |||
* the remote of @p sock. | |||
* @return -ETIMEDOUT, if @p timeout expired. | |||
* @return -EAGAIN, if @p timeout is `0` and no data is available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick-alert: The other return-values are lexicographically ordered ;-)
@@ -207,6 +206,7 @@ int sock_tcp_accept(sock_tcp_queue_t *queue, sock_tcp_t **sock); | |||
* point of @p sock. | |||
* @return -ENOTCONN, when @p sock is not connected to a remote end point. | |||
* @return -ETIMEDOUT, if @p timeout expired. | |||
* @return -EAGAIN, if @p timeout is `0` and no data is available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick-alert: The other return-values are lexicographically ordered ;-)
@@ -395,6 +394,7 @@ int sock_udp_get_remote(sock_udp_t *sock, sock_udp_ep_t *ep); | |||
* @return -EPROTO, if source address of received packet did not equal | |||
* the remote of @p sock. | |||
* @return -ETIMEDOUT, if @p timeout expired. | |||
* @return -EAGAIN, if @p timeout is `0` and no data is available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick-alert: The other return-values are lexicographically ordered ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
* value `> 0`. If an error occurs on receive we just ignore it and continue | ||
* looping. | ||
* value `!= SOCK_NO_TIMEOUT`. If an error occurs on receive we just ignore it | ||
* and continue looping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait... the code above needs adaption to to be in line with that text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the snippet directly above too, please.
* alternatively set the `timeout` parameter of @ref sock_udp_recv() to a | ||
* value `> 0`. If an error occurs on receive we just ignore it and continue | ||
* looping. | ||
* The application then waits indefinitely for an incoming message in `buf` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
I hope I found everything now ^^" |
Could we leave the formatting to "fill lines up to 80 chars, wrap before word"? |
Yapp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot the snippets.
* value `> 0`. If an error occurs on receive we just ignore it and continue | ||
* looping. | ||
* value `!= SOCK_NO_TIMEOUT`. If an error occurs on receive we just ignore it | ||
* and continue looping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the snippet directly above too, please.
* alternatively set the `timeout` parameter of @ref sock_udp_recv() to a | ||
* value `> 0`. If an error occurs on receive we just ignore it and continue | ||
* looping. | ||
* The application then waits indefinitely for an incoming message in `buf` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
I don't see what you mean. Could you point me to file and line? |
Oops, sorry. My bad... You already changed it but I was confused due to the diff layout. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, please squash.
cb4178c
to
aace136
Compare
Follow-up on RIOT-OS#5929
Follow-up on RIOT-OS#5929
IMHO specifying a timeout of "0" for "don't wait at all" makes much more sense.