Skip to content

Commit

Permalink
Fix leak on windows, porting #288 to v5
Browse files Browse the repository at this point in the history
Signed-off-by: Aron Heinecke <aron.heinecke@t-online.de>
  • Loading branch information
0xpr03 committed Apr 14, 2021
1 parent e69d5a2 commit e9525f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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 [#TODO]

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

## 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

0 comments on commit e9525f1

Please sign in to comment.