You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just encountered this while having a look at adding exclusive lock support for #15/#126.
I've managed to get the lock side of things working (I think), but have discovered that when an fopen() multiple times on the same file, the same SeekableFileContent object is returned each time. As a result, the pointer and its position are shared, and successive reads against one file handle will move the pointer for all other file handles which have the file open.
Here's a simple testcase which demonstrates the issue:
I've solved this hackily by storing the current position in the streamWrapper after move operations (read, write, seek, eof, etc.) and then restoring the location before a subsequent operation.
The more correct thing to do would be to do store the position in the fileContent, but that would likely mean huge API changes because most operations on the content currently don't require the resource requesting them -- none of the functions in src/main/php/org/bovigo/vfs/content/SeekableFileContent.php require the resource.
Another solution would be to full clone the content when it is retrieved - e.g. in src/main/php/org/bovigo/vfs/vfsStreamWrapper.php:
I just encountered this while having a look at adding exclusive lock support for #15/#126.
I've managed to get the lock side of things working (I think), but have discovered that when an fopen() multiple times on the same file, the same SeekableFileContent object is returned each time. As a result, the pointer and its position are shared, and successive reads against one file handle will move the pointer for all other file handles which have the file open.
Here's a simple testcase which demonstrates the issue:
I've solved this hackily by storing the current position in the streamWrapper after move operations (read, write, seek, eof, etc.) and then restoring the location before a subsequent operation.
The more correct thing to do would be to do store the position in the fileContent, but that would likely mean huge API changes because most operations on the content currently don't require the resource requesting them -- none of the functions in src/main/php/org/bovigo/vfs/content/SeekableFileContent.php require the resource.
Another solution would be to full clone the content when it is retrieved - e.g. in src/main/php/org/bovigo/vfs/vfsStreamWrapper.php:
However, this means that writes are not store against the VFS properly too.
The text was updated successfully, but these errors were encountered: