Fix a potential deadlock between OnEvent() and Delete() (#40454)
Blue committed
May 7, 2026 at 17:03 UTC
a578ee41761d33291a8de9951d5af3d68ab83108
1 file changed
+6
-7
src/windows/wslcsession/WSLCContainer.cpp
+6
-7
@@ -913,14 +913,13 @@ void WSLCContainerImpl::Delete(WSLCDeleteFlags Flags)
913
{
914
auto lock = m_lock.lock_exclusive();
915
wrapper = DeleteExclusiveLockHeld(Flags);
916
+ }
917
917
- // Wait for the docker destroy event so anonymous volume cleanup is reflected in tracking by
918
- // the time we return. Safe to wait here: OnEvent() signals m_destroyEvent before
919
- // taking m_lock. Callers on the docker event-loop thread (OnEvent) must not wait.
920
- if (WI_IsFlagSet(Flags, WSLCDeleteFlagsDeleteVolumes))
921
- {
922
- m_wslcSession.WaitForEventOrSessionTerminating(m_destroyEvent.get(), 60s);
923
- }
918
+ // Wait for the docker destroy event so anonymous volume cleanup is reflected in tracking by
919
+ // the time we return.
920
+ if (WI_IsFlagSet(Flags, WSLCDeleteFlagsDeleteVolumes))
921
+ {
922
+ m_wslcSession.WaitForEventOrSessionTerminating(m_destroyEvent.get(), 60s);
923
}
924
}
925