TCP listener: avoid buildup of DOWN messages
TCP listeners run separate acceptor processes that they monitor. In the happy path where a client connects, the acceptor process sends a message to the parent, then exits.
That happy path causes two messages to be sent to the parent process: a tcp_connect message and a DOWN message. But the DOWN message was never handled, causing the message queue of the TCP listener to build up and grow unbounded.
The fix consists of demonitoring the process that just gave the TCP listener a socket. For good measure, we give the :flush option, which removes a possible DOWN message from the caller’s message queue. This should be enough to fix the message queue growth problem.
Ideally, this entire module could use an overhaul. The whole thing is hacky because of the need to call :procket.open and :procket.close/1 manually when starting or stopping a listener. There ought to be a smarter way.