Use {shutdown, Error} when terminating connection processes
authorNick Vatamaniuc <vatamane@gmail.com>
Mon, 2 May 2022 19:21:35 +0000 (15:21 -0400)
committerNick Vatamaniuc <vatamane@gmail.com>
Mon, 2 May 2022 22:13:42 +0000 (18:13 -0400)
commite56a4dce6b360c5c5d037e8de33dd267790092e4
tree6c4ab4212e847af5468f2c00fa17c96026fa5775
parentc724c3a41c2e3ec7977fe118058056f0b8d2b8cc
Use {shutdown, Error} when terminating connection processes

Previously they exited `normal`, which helped avoid error log spam. However,
that also meant any linked helper processes would not exit when the main
connection process had been terminated.

To automatically clean up any linked processes, and continue avoiding
generating error logs, we can use `{shutdown, Error}` as the exit reason. That
error, along with `shutdown` atom, are special exit reasons which are
considered `normal` for proc_lib processes and will not generate error logs
[1].

Another benefit is having more specific exit reasons (send error, recv error,
etc.), which may help with debugging.

[1] https://www.erlang.org/docs/24/man/proc_lib.html#description
src/mochiweb_acceptor.erl
src/mochiweb_http.erl
src/mochiweb_request.erl
src/mochiweb_socket.erl
src/mochiweb_websocket.erl