Skip to content

Commit

Permalink
fix: convert session_present flag to boolean to follow the declared…
Browse files Browse the repository at this point in the history
… type
  • Loading branch information
SergeTupchiy committed May 16, 2024
1 parent c815a18 commit 10fc84e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/emqtt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ reconnect(_EventType, _, _State) ->
waiting_for_connack(cast, #mqtt_packet{} = P, State) ->
waiting_for_connack(cast, {P, default_via(State)}, State);
waiting_for_connack(cast, {?CONNACK_PACKET(?RC_SUCCESS,
SessPresent,
SessPresentFlag,
Properties), Via},
State = #state{properties = AllProps,
clientid = ClientId,
Expand All @@ -1052,7 +1052,7 @@ waiting_for_connack(cast, {?CONNACK_PACKET(?RC_SUCCESS,
Reply = {ok, Properties},
State1 = State#state{clientid = assign_id(ClientId, AllProps1),
properties = AllProps1,
session_present = SessPresent},
session_present = flag_to_bool(SessPresentFlag)},
State2 = qoe_inject(connected, State1),
State3 = ensure_retry_timer(ensure_keepalive_timer(State2)),
Retry = [{next_event, info, immediate_retry} || not emqtt_inflight:is_empty(Inflight)],
Expand All @@ -1066,7 +1066,7 @@ waiting_for_connack(cast, {?CONNACK_PACKET(?RC_SUCCESS,
end;

waiting_for_connack(cast, {?CONNACK_PACKET(ReasonCode,
_SessPresent,
_SessPresentFlag,
Properties), Via},
State = #state{proto_ver = ProtoVer, socket = Via, reconnect = Re}) ->
Reason = reason_code_name(ReasonCode, ProtoVer),
Expand Down Expand Up @@ -2255,3 +2255,6 @@ redact_packet(#mqtt_packet{variable = #mqtt_packet_connect{} = Conn} = Packet) -
Packet#mqtt_packet{variable = Conn#mqtt_packet_connect{password = <<"******">>}};
redact_packet(Packet) ->
Packet.

flag_to_bool(0) -> false;
flag_to_bool(1) -> true.

0 comments on commit 10fc84e

Please sign in to comment.