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 leak on windows, porting #288 to v5 #298

Merged
merged 1 commit into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
## unreleased

- FIX: Display proper error message when reaching inotify limits on linux [#285]
- FIX: Fix leaks on Windows [#298]

[#285]: https://github.com/notify-rs/notify/pull/285
[#298]: https://github.com/notify-rs/notify/pull/298

## 5.0.0-pre.6 (2021-02-20)

Expand Down
5 changes: 4 additions & 1 deletion src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ fn stop_watch(ws: &WatchState, meta_tx: &Sender<MetaEvent>) {
let ch = handleapi::CloseHandle(ws.dir_handle);
// have to wait for it, otherwise we leak the memory allocated for there read request
if cio != 0 && ch != 0 {
synchapi::WaitForSingleObjectEx(ws.complete_sem, INFINITE, TRUE);
while synchapi::WaitForSingleObjectEx(ws.complete_sem, INFINITE, TRUE) != WAIT_OBJECT_0
{
// drain the apc queue, fix for https://github.com/notify-rs/notify/issues/287#issuecomment-801465550
}
}
handleapi::CloseHandle(ws.complete_sem);
}
Expand Down