Make termination reason normal for tcp_closed

To avoid lots of error reports, this is a normal case after all…
This commit is contained in:
Hans Svensson 2018-03-07 14:27:19 +01:00
parent 9f2faa3caf
commit 4ebb8c8ec9

View File

@ -63,13 +63,13 @@ handle_info({tcp, TS, Data}, S = #state{ tcp_sock = TS }) ->
{noreply, S2};
handle_info({tcp_closed, TS}, S = #state{ tcp_sock = TS, active = A, owner = O }) ->
[ O ! {tcp_closed, TS} || A ],
{stop, tcp_closed, S};
{stop, normal, S#state{ tcp_sock = undefined }};
handle_info(Msg, S) ->
io:format("Unexpected info: ~p\n", [Msg]),
{noreply, S}.
terminate(Reason, #state{ tcp_sock = TcpSock }) ->
[ gen_tcp:close(TcpSock) || Reason /= tcp_closed ],
terminate(_Reason, #state{ tcp_sock = TcpSock }) ->
[ gen_tcp:close(TcpSock) || TcpSock /= undefined ],
ok.
code_change(_OldVsn, State, _Extra) ->