Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: MQTT fixes #2986

Merged
merged 3 commits into from
Mar 14, 2020
Merged

WIP: MQTT fixes #2986

merged 3 commits into from
Mar 14, 2020

Conversation

nwf
Copy link
Member

@nwf nwf commented Dec 28, 2019

Some minor changes and one major fix to the MQTT module. Not yet tested beyond "it compiles".

  • This PR is for the dev branch rather than for master.
  • This PR is compliant with the other contributing guidelines as well (if not, please describe why).
  • I have thoroughly tested my contribution.
  • The code changes are reflected in the documentation at docs/*.

nwf added 3 commits December 28, 2019 13:01
This makes it just like all the other callbacks in the module and is a
revision of behavior called out in
nodemcu#2967
The confusingly-named "mqtt_connection_t" object is just a triple of
  - a serialized mqtt message pointer and length
  - a buffer pointer (to which the above can be written)
  - a message identifier

The last of these must be passed around the mqtt state machine, but the
first two are very local and the buffer is always sourced from the C
stack.  Unfortunately, because the entire structure is persisted in the
heap, some callers assume that they can always use the structure without
reinitialization (see mqtt_socket_close), which will trash the C stack.

Sever the pairing between message id and local state, punt the local
state entirely out of the heap, and rename things to be less confusing.
@marcelstoer marcelstoer added this to the Next release milestone Dec 28, 2019
@marcelstoer
Copy link
Member

Some minor changes and one major fix

Do we have issues for those?

@nwf
Copy link
Member Author

nwf commented Dec 29, 2019

I did not create issues, no.

@nwf nwf merged commit 787ac7c into nodemcu:dev Mar 14, 2020
@nwf nwf deleted the dev-mqtt-fixes branch March 14, 2020 22:51
@nwf
Copy link
Member Author

nwf commented Mar 14, 2020

Hearing no objections, I'm going to merge my own fixes and see who screams. ;)

marcelstoer pushed a commit that referenced this pull request Jun 9, 2020
* mqtt: expose "connfail" callback via :on()

This makes it just like all the other callbacks in the module and is a
revision of behavior called out in
#2967

* mqtt: clarify when puback callback fires

* mqtt: Don't reference stack buffers from the heap

The confusingly-named "mqtt_connection_t" object is just a triple of
  - a serialized mqtt message pointer and length
  - a buffer pointer (to which the above can be written)
  - a message identifier

The last of these must be passed around the mqtt state machine, but the
first two are very local and the buffer is always sourced from the C
stack.  Unfortunately, because the entire structure is persisted in the
heap, some callers assume that they can always use the structure without
reinitialization (see mqtt_socket_close), which will trash the C stack.

Sever the pairing between message id and local state, punt the local
state entirely out of the heap, and rename things to be less confusing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants