Commit c6b281a8 authored by Jeffrey Lee's avatar Jeffrey Lee Committed by ROOL
Browse files

Fix fsfile_ReadInfo blockifwriting logic

When handling fsfile_ReadInfo, PipeFS wants to wait for any writer to
close the file before returning the file information. To do this it
repeatedly calls FindFileOrDirectory & blockifwriting in a loop until
that condition is reached (or the file ceases to exist). However the
call to FindFileOrDirectory was replacing the filename in R1 with a the
internal file handle (i.e. a pointer to a struct), so on the second loop
round it would always exit out with a "file not found" response.

This bug had the effect that attempting to read the size of a file (e.g.
using OS_File 5 or *FileInfo) which is open for write would always
report that the file doesn't exist, even if the blockifwriting call
successfully blocks until the writer closes the file.

Restoring R1 before looping back round will give the behaviour the
programmer originally intended, for better or worse (e.g. current
versions of FileSwitch use fsfile_ReadInfo to check the file before
trying to open it, so trying to use OPENIN on a file which is open for
write will unintentionally block - a bug that was hidden on earlier
versions of RISC OS because prior to TaskWindow 0.65, TaskWindow didn't
make any attempt to wait until the pollword was non-zero before
returning, so PipeFS would pretty quickly exit out with a harmless "file
not found" response due to the register corruption bug)
parent 57004a85
......@@ -642,8 +642,13 @@ PipeFS_OSFile EntryS "R1,R7,R9"
BL blockifwriting ; this may be bad news, if we are reading the file
EXIT VS ; since it will never be unblocked
EXIT EQ
B %b20 ; file still open
EXIT EQ ; file wasn't open for write
; We (probably) slept and the file is now (possibly) no longer open for
; write. The attributes we loaded could be out of date, or the file
; might not exist any more, or it could still be open for write. So go
; back round to the filename search so we can check everything again.
FramLDR r1
B %b20
; read file info without length
; in: R1 -> wildcarded filename
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment