Skip to content
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

2 possible race conditions #5

Open
lilith opened this issue Sep 17, 2014 · 0 comments
Open

2 possible race conditions #5

lilith opened this issue Sep 17, 2014 · 0 comments

Comments

@lilith
Copy link

lilith commented Sep 17, 2014

  1. (Difficult to reproduce without a slow filesystem) As soon as you open a FileStream, the file exists. However, that doesn't mean it contains anything. Since the IIS vs managed decision is made based on the existence of the file, and since (based on my tests) IIS does not block to wait for file read access (it ignores open handles, and reads the file anyway - or, sometimes with some network shares, fails immediately with an exception), you will get corrupt data or an 500.
  2. (Should be easier to reproduce) When two requests for the same resource arrive at similar times (during the remote download), the last file to download will fail with a file access error.

A way to mitigate both issues is to download to a random temporary file, then move the complete file to the final location. If the move fails, you assume the download completed on another thread and delete the temp file.

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

No branches or pull requests

1 participant