revert(ds): Don't duplicate the clean start in session_ds

This commit is contained in:
ieQu1 2023-11-26 19:18:59 +01:00
parent 839f9dbedb
commit bd7a84fe3e
1 changed files with 14 additions and 15 deletions

View File

@ -153,8 +153,6 @@ open(#{clientid := ClientID} = _ClientInfo, ConnInfo) ->
%% somehow isolate those idling not-yet-expired sessions into a separate process
%% space, and move this call back into `emqx_cm` where it belongs.
ok = emqx_cm:discard_session(ClientID),
case maps:get(clean_start, ConnInfo, false) of
false ->
case session_open(ClientID, ConnInfo) of
Session0 = #{} ->
ensure_timers(),
@ -163,10 +161,6 @@ open(#{clientid := ClientID} = _ClientInfo, ConnInfo) ->
{true, Session, []};
false ->
false
end;
true ->
session_drop(ClientID),
false
end.
ensure_session(ClientID, ConnInfo, Conf) ->
@ -554,7 +548,7 @@ session_open(SessionId, NewConnInfo) ->
EI = expiry_interval(ConnInfo),
case ?IS_EXPIRED(NowMS, DisconnectedAt, EI) of
true ->
%% Should we drop the session now, or leave it to session GC?
session_drop(SessionId),
false;
false ->
%% new connection being established
@ -831,8 +825,13 @@ session_drop_pubranges(DSSessionId) ->
%%--------------------------------------------------------------------------------
transaction(Fun) ->
case mnesia:is_transaction() of
true ->
Fun();
false ->
{atomic, Res} = mria:transaction(?DS_MRIA_SHARD, Fun),
Res.
Res
end.
ro_transaction(Fun) ->
{atomic, Res} = mria:ro_transaction(?DS_MRIA_SHARD, Fun),