sock: change "no timeout" value from 0 to UINT32_MAX#5929
sock: change "no timeout" value from 0 to UINT32_MAX#5929miri64 merged 1 commit intoRIOT-OS:masterfrom
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 |
sys/include/net/sock/ip.h
Outdated
| * @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.
You mean "the operation is non-blocking"? "return immediately" sounds more like implementation-speak...
There was a problem hiding this comment.
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.
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. |
|
@miri64 I think I got all your comments? |
miri64
left a comment
There was a problem hiding this comment.
One last wording issue. Other then that I'm fine with this PR.
sys/include/net/sock/ip.h
Outdated
| * @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.
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.
so "the function returns immediately." ?
sys/include/net/sock/tcp.h
Outdated
| * @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. |
sys/include/net/sock/udp.h
Outdated
| * @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. |
| * 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.
Minor question: Why did you change the line wrapping here?
There was a problem hiding this comment.
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.
I prefer the @ref and SOCK_NO_TIMEOUT to be on the same line
There was a problem hiding this comment.
Yeah, but together with the line change above the line would cross the 80 characters mark...
There was a problem hiding this comment.
You could put the line change before the @ref or even the value != ;-)
sys/include/net/sock/ip.h
Outdated
| * @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.
Nitpick-alert: The other return-values are lexicographically ordered ;-)
sys/include/net/sock/tcp.h
Outdated
| * 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.
Nitpick-alert: The other return-values are lexicographically ordered ;-)
sys/include/net/sock/udp.h
Outdated
| * @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.
Nitpick-alert: The other return-values are lexicographically ordered ;-)
| * 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.
Wait... the code above needs adaption to to be in line with that text.
There was a problem hiding this comment.
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` |
|
I hope I found everything now ^^" |
Could we leave the formatting to "fill lines up to 80 chars, wrap before word"? |
|
Yapp |
| * 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.
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` |
|
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. |
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.