Fix crashes when auth failed (#2736)

This commit is contained in:
Shawn 2019-08-09 16:02:04 +08:00 committed by tigercl
parent ddc25be915
commit 68bf72ce04
1 changed files with 7 additions and 2 deletions

View File

@ -74,7 +74,7 @@ info(#protocol{client = Client,
will_msg = WillMsg, will_msg = WillMsg,
topic_aliases = Aliases}) -> topic_aliases = Aliases}) ->
#{client => Client, #{client => Client,
session => emqx_session:info(Session), session => session_info(Session),
proto_name => ProtoName, proto_name => ProtoName,
proto_ver => ProtoVer, proto_ver => ProtoVer,
keepalive => Keepalive, keepalive => Keepalive,
@ -606,7 +606,7 @@ auth_connect(#mqtt_packet_connect{client_id = ClientId,
{ok, AuthResult} -> {ok, AuthResult} ->
{ok, PState#protocol{client = maps:merge(Client, AuthResult)}}; {ok, PState#protocol{client = maps:merge(Client, AuthResult)}};
{error, Reason} -> {error, Reason} ->
?LOG(warning, "Client ~s (Username: '~s') login failed for ~p", ?LOG(warning, "Client ~s (Username: '~s') login failed for ~0p",
[ClientId, Username, Reason]), [ClientId, Username, Reason]),
{error, emqx_reason_codes:connack_error(Reason)} {error, emqx_reason_codes:connack_error(Reason)}
end. end.
@ -916,3 +916,8 @@ sp(false) -> 0.
flag(true) -> 1; flag(true) -> 1;
flag(false) -> 0. flag(false) -> 0.
session_info(undefined) ->
undefined;
session_info(Session) ->
emqx_session:info(Session).