Skip to content

Conversation

tmedicci
Copy link
Contributor

Summary

Previously, if the read bytes were less than the requested, the file was closed immediately. This behavior, however, does not consider the fact that the read operation may be blocking when no bytes are available at the moment. That is true for a named pipe (FIFO), for instance. Thus, reading it again lets to the underlying file system the decision of 1) blocking until bytes become available or 2) return 0 immediately (the case for actual files) or 3) read available bytes.

Impact

No impact on actual files: if the file has reached its end, the second read operation will return 0 and the file will be closed.
It enables, however, using files that read may block to wait for new bytes to become available. That is the case for named pipes (FIFO).

Testing

Tested on ESP32-LyraT board using an actual file (romfs), a HTTP streamed file, and a continuously fed named pipe (mkfifo + rtpdump).

Previously, if the read bytes were less than the requested, the
file was closed immediately. This behavior, however, does not
consider the fact that the read operation may be blocking when
no bytes are available at the moment. That is true for a named pipe
(FIFO), for instance. Thus, reading it again lets to the underlying
file system the decision of 1) blocking until bytes become
available or 2) return 0 immediately (the case for actual files) or
3) read available bytes.
@acassis
Copy link
Contributor

acassis commented Mar 17, 2023

@masayuki2009 please confirm this change

@masayuki2009 masayuki2009 merged commit 3a1893b into apache:master Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants