Skip to content

Commit

Permalink
Handle adding remote processes as handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwalker committed Oct 21, 2014
1 parent b10e297 commit de8c457
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/exirc/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,15 @@ defmodule ExIrc.Client do
end

defp do_add_handler(pid, handlers) do
case Process.alive?(pid) and not Enum.member?(handlers, pid) do
node = Kernel.node(pid)
local_node = Kernel.self()
should_add? = case node do
^local_node ->
Process.alive?(pid) and not Enum.member?(handlers, pid)
_ ->
:rpc.call(node, :erlang, :is_process_alive, [pid])
end
case should_add? do
true ->
ref = Process.monitor(pid)
[{pid, ref} | handlers]
Expand All @@ -651,7 +659,7 @@ defmodule ExIrc.Client do
Process.demonitor(ref)
List.keydelete(handlers, pid, 0)
nil ->
handlers
handlers
end
end

Expand Down

0 comments on commit de8c457

Please sign in to comment.