diff --git a/CHANGELOG.md b/CHANGELOG.md index 0334a2f9..51341ef0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/windows.rs b/src/windows.rs index 12359c7f..620b621e 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -235,7 +235,10 @@ fn stop_watch(ws: &WatchState, meta_tx: &Sender) { 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); }