phoenixframework/phoenix — pull request #548 by fishcakez (2014-12-15 15:42:59+00:00)
Title: Allow "normal" exit of websocket with `exit(:shutdown)`

This is a rather subtle OTP exit reason change. If you try calling `exit(:shutdown)` in a channel with this patch you will observe that logs nolonger appear. This means we are generating a "normal" exit reason, and so can also shutdown linked processes cleanly. A longer explanation is available below/in the commit message:

Previously it was not possible to exit a websocket channel and shutdown linked processes without an abnormal reason exit reason. If `exit(:shutdown)` was called the process would exit with `{{:shutdown, mfa2}, mfa1}`, which is abnormal. The inner `mfa2`, has been removed so that `exit(:shutdown)` causes an exit with `{:shutdown, mfa1}`. This means that linked processes (that don't trap exits) will nolonger exit abnormally on receiving the exit signal, allowing transient shutdown.

This change also means that no log message is produced for the websocket process and any linked supervised process that is temporary or transient if `exit(:shutdown)` is called.

This patch is also nice as it simplifies the code and the `mfa2` mentioned above is actually a phoenix internal that is never exposed in public API.