hannobraun / inotify-rs

Idiomatic inotify wrapper for the Rust programming language
ISC License
260 stars 65 forks source link

Ensure file descriptor is closed on drop #140

Closed tomasvdw closed 4 years ago

tomasvdw commented 4 years ago

This fixes the incorrect initialization of close_on_drop, which caused the file descriptor to never be released because close_on_drop is never true.

tomasvdw commented 4 years ago

I didn't add a test as that's a bit tricky, but I tested manually with println!'s alongside both ffi::close calls and running a test with --nocapture.

Also, the mysterious "too many open file" errors I was debugging for a while in my project are gone now.

hannobraun commented 4 years ago

Thank you, @tomasvdw! I'll try to get a point release out with this fix before Christmas.

cuviper commented 4 years ago

Hi - I see that 0.8.1 is supposed to have this change, but somehow it's missing in the published package on crates.io. The src/ directories of 0.8.0 and 0.8.1 are identical.

cuviper commented 4 years ago

The package's .cargo_vcs_info.json says it was commit f26f6ff9856190c630828ebf26f307071e2d8dbf, which is the last commit in #142 for the release. However, that PR wasn't current with master:

$ git log --oneline f26f6ff9856190c630828ebf26f307071e2d8dbf..master
b0805d9957f7 (HEAD -> master, origin/master, origin/HEAD) Merge pull request #142 from hannobraun/release-0.8.1
c3d57ea8f2f6 Merge pull request #141 from JohnTitor/license
8addc45f7a26 Merge pull request #140 from tomasvdw/fix_fd_close
52c18c527fe2 Add LICENSE file
113397052060 Ensure file descriptor is closed on drop
hannobraun commented 4 years ago

Oh man, I must have forgotten a git pull before branching for the release. Sorry for the trouble. I'll release a new version soon.

hannobraun commented 4 years ago

Version 0.8.2 is now out. Thank you everyone, and sorry again for the mistake.

cuviper commented 4 years ago

Thanks, LGTM!