Gracefully handle clients that close their connection after logout

Registrar portal behaves closes the connection on its own after
sending logout command, we should not throw errors with those cases.
This commit is contained in:
Maciej Szlosarczyk 2019-07-11 09:54:32 +03:00
parent 4bc8821472
commit 4830a7e5e2
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765

View file

@ -101,8 +101,10 @@ handle_cast(process_command,
%% On logout, close the socket. %% On logout, close the socket.
%% Else, go back to the beginning of the loop. %% Else, go back to the beginning of the loop.
if Command =:= "logout" -> if Command =:= "logout" ->
ok = ssl:shutdown(Socket, read_write), case ssl:shutdown(Socket, read_write) of
{stop, normal, State}; ok -> {stop, normal, State};
{error, closed} -> {stop, normal, State}
end;
true -> true ->
gen_server:cast(self(), process_command), gen_server:cast(self(), process_command),
{noreply, {noreply,