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

Fix file handle leak in read #139

Merged
merged 4 commits into from
Feb 6, 2025

Conversation

arielshaqed
Copy link
Contributor

No description provided.

@arielshaqed
Copy link
Contributor Author

The actual fix is onRead, and tests are about 19x longer. Apologies for the extra work loaded onto the actual fix 👼🏽

(Useful for _my_ tests, should not be upstreamed)
Copy link
Owner

@willscott willscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks especially for the test!

Copy link

@yonipeleg33 yonipeleg33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @arielshaqed!
Just had a couple of questions, leaving the real review to @willscott of course 🙂

}
t.mu.Lock()
defer t.mu.Unlock()
id := rand.Int63()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Isn't the filename sufficient?
And if not, why not use a UUID, or even an atomically incremented ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files can be open multiple times, and OpenFile can be called multiple time with the exact same arguments. We need a "unique" ID.

Obviously a more unique ID would be better. But this is a test. As long as the test opens fewer than 10 or so million files, we should be cool.

ObMeme Dr Evil: "One MILLION files!"

@arielshaqed
Copy link
Contributor Author

Thanks! Sorry about that nasty leftover in go.mod .

@willscott willscott merged commit 7070f5a into willscott:master Feb 6, 2025
3 checks passed
@arielshaqed
Copy link
Contributor Author

Thanks! 37 minutes to review an external PR has got to be a record...

@willscott
Copy link
Owner

willscott commented Feb 6, 2025 via email

@arielshaqed arielshaqed deleted the bug/close-on-read branch February 6, 2025 11:02
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

Successfully merging this pull request may close these issues.

3 participants