this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix dead processes not being cleaned up

garrison 0355faf8 646440fc

+15 -17
+9 -4
lib/trinity/scheduler.ex
··· 225 225 :ok 226 226 end 227 227 228 - def handle_down(%Simulation{} = sim, _pid, :normal) do 228 + def handle_down(%Simulation{} = sim, pid, :normal) do 229 229 %{queue: queue, proc_queue_keys: proc_queue_keys} = sim 230 + destroy_process(sim, pid) 230 231 perform_next(queue, proc_queue_keys, sim.now) 231 232 [] 232 233 end ··· 235 236 %{queue: queue, proc_queue_keys: proc_queue_keys, proc_links: proc_links} = sim 236 237 linked = gather_linked(pid, proc_links) 237 238 238 - Enum.each(linked, fn pid -> 239 - destroy_process(sim, pid) 240 - Process.exit(pid, reason) 239 + destroy_process(sim, pid) 240 + Enum.each(linked, fn lp -> 241 + destroy_process(sim, lp) 242 + Process.exit(lp, reason) 243 + receive do 244 + {:EXIT, ^lp, _reason} -> :noop 245 + end 241 246 end) 242 247 243 248 perform_next(queue, proc_queue_keys, sim.now)
+6 -13
lib/trinity/scheduler/simulation_supervisor.ex
··· 97 97 exit(reason) 98 98 99 99 ^root_pid -> 100 - # The root has died, end the simulation 100 + # The root died, end the simulation 101 101 end_simulation(state, reason) 102 102 {:noreply, state} 103 103 104 104 _ -> 105 105 killed = Trinity.Scheduler.handle_down(sim, from, reason) 106 106 107 - Enum.each(killed, fn pid -> 108 - # Flush exit messages for (simulated) linked processes 109 - receive do 110 - {:EXIT, ^pid, _reason} -> :noop 111 - end 112 - 113 - # If the root was killed, end the simulation 114 - case pid == root_pid do 115 - true -> end_simulation(state, reason) 116 - _ -> :noop 117 - end 118 - end) 107 + case root_pid in killed do 108 + # The root was linked and therefore killed, end the simulation 109 + true -> end_simulation(state, reason) 110 + _ -> :noop 111 + end 119 112 120 113 {:noreply, state} 121 114 end