Should not exit arbitrarily if clientid conflicts in mnesia
This commit is contained in:
parent
d9500412bf
commit
d2a4e2c615
|
@ -213,7 +213,7 @@ process(?CONNECT_PACKET(Var), State0) ->
|
||||||
%% ACCEPT
|
%% ACCEPT
|
||||||
{?CONNACK_ACCEPT, SP, State2#proto_state{session = Session, is_superuser = IsSuperuser}};
|
{?CONNACK_ACCEPT, SP, State2#proto_state{session = Session, is_superuser = IsSuperuser}};
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
exit({shutdown, Error})
|
{stop, {shutdown, Error}, State2}
|
||||||
end;
|
end;
|
||||||
{error, Reason}->
|
{error, Reason}->
|
||||||
?LOG(error, "Username '~s' login failed for ~p", [Username, Reason], State1),
|
?LOG(error, "Username '~s' login failed for ~p", [Username, Reason], State1),
|
||||||
|
@ -381,12 +381,12 @@ stop_if_auth_failure(_RC, State) ->
|
||||||
|
|
||||||
shutdown(_Error, #proto_state{client_id = undefined}) ->
|
shutdown(_Error, #proto_state{client_id = undefined}) ->
|
||||||
ignore;
|
ignore;
|
||||||
|
shutdown(conflict, _State) ->
|
||||||
shutdown(conflict, #proto_state{client_id = _ClientId}) ->
|
%% let it down
|
||||||
|
ignore;
|
||||||
|
shutdown(mnesia_conflict, _State) ->
|
||||||
%% let it down
|
%% let it down
|
||||||
%% emqttd_cm:unreg(ClientId);
|
|
||||||
ignore;
|
ignore;
|
||||||
|
|
||||||
shutdown(Error, State = #proto_state{will_msg = WillMsg}) ->
|
shutdown(Error, State = #proto_state{will_msg = WillMsg}) ->
|
||||||
?LOG(debug, "Shutdown for ~p", [Error], State),
|
?LOG(debug, "Shutdown for ~p", [Error], State),
|
||||||
Client = client(State),
|
Client = client(State),
|
||||||
|
|
|
@ -216,8 +216,7 @@ code_change(_OldVsn, State, _Extra) ->
|
||||||
create_session({CleanSess, {ClientId, Username}, ClientPid}, State) ->
|
create_session({CleanSess, {ClientId, Username}, ClientPid}, State) ->
|
||||||
case create_session(CleanSess, {ClientId, Username}, ClientPid) of
|
case create_session(CleanSess, {ClientId, Username}, ClientPid) of
|
||||||
{ok, SessPid} ->
|
{ok, SessPid} ->
|
||||||
{reply, {ok, SessPid, false},
|
{reply, {ok, SessPid, false}, monitor_session(ClientId, SessPid, State)};
|
||||||
monitor_session(ClientId, SessPid, State)};
|
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
{reply, {error, Error}, State}
|
{reply, {error, Error}, State}
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in New Issue