-
Notifications
You must be signed in to change notification settings - Fork 979
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
[Wip] Add an implementation of ReadAsync to PartialInputStream #589
base: master
Are you sure you want to change the base?
[Wip] Add an implementation of ReadAsync to PartialInputStream #589
Conversation
@piksel Do you have any thoughts on the importance of the locks used in the existing PartialInputStream read functions, or on the best way to approach them in any async implementation? The common suggestion seems to be to use |
I think using Stream.Synchronized(Stream) should be roughly equivalent to using Now, the problem is that it would still not be restricting code outside our library from altering the base stream. At least I don't think so. Using |
As in, create the partial input stream from a synchronized stream, rather than the base stream? Would that work in the case of |
I don't know if you can really prevent a caller who constructed a ZipFile from an arbitrary stream from changing that stream themselves outside of the library code - even if |
Yeah, I just don't know what else this is meant to do? The original code is synchronous, so what was the point? Also |
I guessed that it was to try to avoid issues if the user tries to simultaneously read the content from multiple zip entries at the same time from different threads (given that nothing in the library itself should try to do anything like that). The lock at
|
Spin off from comments in #576 - Where it looked like PartialInputStream needed an implementation of
ReadAsync
in order for async read calls against the streams returned fromZipFile.GetInputStream
to actually do async reads from the base stream.It's WIP because I'm not sure what the situation should be with the locks around
baseStream_
in the existing Read function, becauseawait
insidelock
seems to not be allowed.I assume the locks are an attempt to prevent issues if someone tries to read from multiple zip entries at the same time, and they all try to manipulate the base stream?
I certify that I own, and have sufficient rights to contribute, all source code and related material intended to be compiled or integrated with the source code for the SharpZipLib open source product (the "Contribution"). My Contribution is licensed under the MIT License.