Skip to content

Commit cde686f

Browse files
Marcello Serilindig
authored andcommitted
CA-270640: Avoid leaking waker threads
If we receive unexpected responses from emu-manager, the handle_result loop exits immediately, potentially leaving "requests" threads blocked and waiting to be woken up. This can be avoided by waking up all the remaining threads in a finalizer loop. This does not solve the potential leak of the reader threads. Signed-off-by: Marcello Seri <[email protected]>
1 parent 6f4bbf7 commit cde686f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

xc/domain.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,11 @@ module Suspend_restore_emu_manager : SUSPEND_RESTORE = struct
10451045
loop (result :: results)
10461046
end else begin
10471047
error "Received unexpected response from emu-manager";
1048+
(* Exhaust the thread_requests before returning the error,
1049+
* this prevenst leaking blocked results threads *)
1050+
List.iter (fun (emu, wakeup) ->
1051+
Event.send wakeup () |> Event.sync)
1052+
!thread_requests;
10481053
`Error Domain_restore_failed
10491054
end
10501055
with End_of_file ->

0 commit comments

Comments
 (0)