Skip to content

fix: convert session_present flag to boolean to follow the declared type#242

Open
SergeTupchiy wants to merge 1 commit into
masterfrom
fix-session_present-type
Open

fix: convert session_present flag to boolean to follow the declared type#242
SergeTupchiy wants to merge 1 commit into
masterfrom
fix-session_present-type

Conversation

@SergeTupchiy

Copy link
Copy Markdown

No description provided.

@SergeTupchiy

Copy link
Copy Markdown
Author

NOTE: it will break a few tests in emqx.

Comment thread src/emqtt.erl
redact_packet(Packet) ->
Packet.

flag_to_bool(0) -> false;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, can be fixed in https://github.com/emqx/emqtt/blob/fix-session_present-type/src/emqtt_frame.erl#L218
similarly to how CONNECT packet flags are parsed to bools: https://github.com/emqx/emqtt/blob/fix-session_present-type/src/emqtt_frame.erl#L202

But it would require changing the record field, e.g:

#mqtt_packet_connack{session_present  = SessionPresent,

Instead of:

#mqtt_packet_connack{ack_flags   = AckFlags,

@qzhuyan

qzhuyan commented May 16, 2024

Copy link
Copy Markdown
Contributor

I think it is a good change but may break many places, worth it?
Do you have a good reason?

@SergeTupchiy

Copy link
Copy Markdown
Author

I think it is a good change but may break many places, worth it? Do you have a good reason?

No reason, besides improving consistency (other flags are converted and stored as boolean).
In emqx session_present flag is only used in a few test cases which would be easy to fix.

Instead of this fix, we may change type of session_present to integer: https://github.com/emqx/emqtt/blob/master/src/emqtt.erl#L252 ?

@thalesmg

Copy link
Copy Markdown
Contributor

I think it is a good change but may break many places, worth it? Do you have a good reason?

No reason, besides improving consistency (other flags are converted and stored as boolean). In emqx session_present flag is only used in a few test cases which would be easy to fix.

Instead of this fix, we may change type of session_present to integer: https://github.com/emqx/emqtt/blob/master/src/emqtt.erl#L252 ?

IMO, using a boolean is more semantic for this case. Maybe we could indicate this is a breaking change with a major version bump?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants