-
Notifications
You must be signed in to change notification settings - Fork 1.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
drivers/pipes: return after short write if buffer is full #14667
Conversation
The write should return even in case of O_NONBLOCK if at least some bytes were written. The previous state where always all bytes were written was breaking a common combination with poll, because poll would signal POLLOUT and some bytes would really be consumed but write could still block afterwards. That would prevent from execution returning to the poll loop again. None the less it is also the standard C library behavior for the write function.
[Experimental Bot, please feedback here] Yes, this PR appears to meet the NuttX requirements, although some sections could be more explicit. Strengths:
Areas for Improvement:
Example of improved Testing Section:
tlen 295
tlen 295
By making these improvements, the PR will be clearer, easier to review, and demonstrate a higher level of due diligence. |
Sorry @Cynerd: CI Test in arm-02 is failing with Pipe Timeout, I wonder if it's due to this PR?
https://github.com/NuttX/nuttx/actions/runs/11713931118/job/32627704349#step:7:174 Update: CI Test is also super slow in sim-01 and risc-v-05, taking 6 hours (before getting killed by GitHub): |
It might be. I will look into that. I suspect that it is because of some invalid expectations for some components using the pipe. As I wrote in the "Impact": it might cause issues if code that uses pipecommon relies on write working in a non-standard way. Edit: The Edit2: @lupyuen apache/nuttx-apps#2829 |
Summary
The write should return even in case of O_NONBLOCK if at least some bytes were written.
The previous state where always all bytes were written was breaking a common combination with poll, because poll would signal POLLOUT and some bytes would really be consumed but write could still block afterwards. That would prevent from execution returning to the poll loop again.
None the less it is also the standard C library behavior for the write function.
Impact
This could have impack on any code that uses pipes and fifos and relies on this non-standard behavior or
write
always writing all bytes. But it is non-standard behavior and thus considered to be a bug in my eyes.Testing
Tested with the following code that after this change works: