Ticket #480 (Fixed)Wed Mar 11 10:11:49 UTC 2020
PipeFS : hangs on open for read when open for write
Reported by: | Chris Johns (8262) | Severity: | Normal |
Part: | RISC OS: Module | Release: | |
Milestone: | Status | Fixed |
Details by Chris Johns (8262):
Open two task windows.
In one:
*BASIC
X=OPENOUT
in the other:
*BASIC
Y=OPENIN
Note that the second task window now hangs (until the file is closed in the first one).
I would expect the OPENIN to succeed (although trying to read a byte would hang until one was made available by the writing end). This is what 4.39 does, but I’ve not tried on other versions.
Using RISC OS 5.27 (03-Nov-19) on RPCEmu.
Changelog:
Modified by Chris Johns (8262) Wed, March 11 2020 - 10:13:33 GMT
The ticket seems to have made a mess of the exmaple .. in one task window use OPENOUT to open a file in PipeFS, in the other use OPENIN on the same file.
Modified by Chris Johns (8262) Tue, March 17 2020 - 11:16:29 GMT
- Summary changed from PipeFS hangs on open to PipeFS : hangs on open for read when open for write
Futher investigation seems to show that opening the read side first seems to be ok.
Modified by Jeffrey Lee (213) Sun, January 08 2023 - 12:18:57 GMT
Some more observations:
- After the writer closes the file, if the reader repeatedly reads bytes then once it reaches the end of the data that was written it’ll read one extra byte (254) before getting EOF
- If the writer closes the file while the reader is blocked for read, the reader will remain blocked (can be unblocked by having something else open the file and write to it)
Modified by Jeffrey Lee (213) Sun, January 08 2023 - 14:32:06 GMT
Ah, I forgot that (a) when reaching EOF, OS_BGet first returns with C set before raising an EOF error on the next call, and (b) BASIC BGET doesn’t pass on the C set response from OS_BGet in any way. So getting one extra (supposedly undefined) byte from BGET is to be expected.
But the second observation of mine is valid (and looks easy enough to fix by having PipeFS wake the reader when closing the writer).
Modified by Jeffrey Lee (213) Thu, January 12 2023 - 21:28:30 GMT
I’ve got a fix for the “reader being blocked after writer closes” ready to go. So now I’m back to the problem mentioned at the start of this ticket.
Testing on RO 3.7 shows that things work correctly (opening for read doesn’t block), and there’s nothing jumping out at me in the PipeFS commit history, so it looks like it’s going to be a case of manually testing some older versions of components to see where it broke and why.
Modified by Jeffrey Lee (213) Sat, January 14 2023 - 20:11:55 GMT
Original problem should be fixed by this pending FileSwitch change https://gitlab.riscosopen.org/RiscOS/Sources/Fi…
“Reader remains blocked after writer closes the file” should be fixed by this PipeFS change, along with a couple of other things: https://gitlab.riscosopen.org/RiscOS/Sources/Fi…
See also this forum thread where I talked about the problems a bit: https://www.riscosopen.org/forum/forums/4/topic…
Modified by Sprow (202) Tue, January 24 2023 - 12:50:42 GMT
- Status changed from Open to Fixed
Fixed in PipeFS 0.25 along with changes in FileSwitch 2.90