bitwalker/exirc — pull request #18 by jeffweiss (2014-10-21 20:26:20+00:00)
Title: simplify ExIrc.Client.do_add_handler/2 logic

Prior to this commit the `do_add_handler` function would do lots of work
to check to see if the handler process was alive (either on the local
node or a remote node); however, this work not comprehensive because the
process could die between the `alive?` check and `Process.monitor/1`, but
also unneccesary, because the semantics of `Process.monitor/1` (and
`:erlang.monitor/2`) will guarantee that the monitoring process will be
sent a `{:DOWN, _, _, _, _}` message if the monitored process dies,
doesn't exist or the node hosting the process disconnects from the mesh.
Because `Process.monitor/1` notifies the monitoring process if the
monitored process is dead by the time we add it, we can remove the
checks to validate that the handler process is alive and instead rely on
the semantics of `Process.monitor/1` and simplify our logic.
This commit also fixes the handling of the `{:DOWN, _, _, _, _}` message
because previously we were checking for the Erlang variant of it as
`{'DOWN', _, _, _, _}`, and thus, our handler removal upon process death
was never getting properly called.