-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
kernel: pipe: should return if >= min_xfer bytes transferred and timeout is K_FOREVER #24485
Comments
Yep. |
While I agree the documentation could be interpreted the way you do, and that it might be useful if it worked that way, it seems the implementation respects "immediately satisfied" and "fail immediately" only in the case of If your interpretation is to be supported I don't think your proposed solution in #24486 will work because at the point you discover that the minimum transfer hasn't been satisfied immediately some bytes may have been transferred, and they can't be clawed back, so failure will cause lost data. I suspect a proper solution would be to modify But first it has to be confirmed that this is a bug, rather than misleading documentation. |
I guess technically, if K_NO_WAIT is specified, then the documentation is consistent. However, I see no way to perform blocking I/O without entirely pre-determined data lengths. To be completely transparent, it is #24426 that is blocked. |
I interpreted the API documentation to mean that if I called Technically speaking, if an error occurs and some bytes have been read, the the number of bytes read is still available in |
@andyross could you take a look? |
Yeah, that "min_xfer" is an ugly wart. But I think I agree with @cfriedt that it can only reasonably be interpreted as having higher precedence than the timeout. That is, what we want is: "Here is some data (or a buffer to receive data), please transfer at least this many bytes of it, if necessary waiting this long to do it before returning" But what we've implemented is: "Here is some data (or buffer), please transfer all of it, if necessary waiting this long before returning, but as a special case it's OK to return early if you can synchronously move this smaller amount instead". Yeah, we're wrong, even if you can squint and make us legal per our vague docs. The PR looks good, I'll put comments there. |
Thanks for having a look @andyross @carlescufi |
If timeout != K_NO_WAIT, then return immediately when not all bytes_to_read or bytes_to_write have been transfered, but >= min_xfer have been transferred. Fixes #24485 Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
If timeout != K_NO_WAIT, then return immediately when not all bytes_to_read or bytes_to_write have been transfered, but >= min_xfer have been transferred. Fixes zephyrproject-rtos#24485 Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
If timeout != K_NO_WAIT, then return immediately when not all bytes_to_read or bytes_to_write have been transfered, but >= min_xfer have been transferred. Fixes zephyrproject-rtos#24485 Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
Describe the bug
The following code hangs indefinitely at
k_pipe_get()
, but it should not, according to the documentation:To Reproduce
Steps to reproduce the behavior:
Expected behavior
As per the documentation
Since "the specified minimum number of bytes can be immediately satisfied", the call to
k_pipe_get()
should return immediately.Impact
This is a showstopper for me if I would like to continue using the k_pipe API.
Screenshots or console output
Environment (please complete the following information):
Additional context
I can make a PR. Have a patch for it already. I wonder though if
k_pipe_put()
has the same problem. Will investigate.The text was updated successfully, but these errors were encountered: