net/emcute: unlock txlock on connect errors - #22423
Conversation
|
Hey @Old-Ding, thank you for your first contribution! We really appreciate it! If you haven't already, please take a look at our contributing guidelines before the review process starts. Also, due to how the GitHub review system works, please avoid force-pushing or squashing your commits unless asked to by a maintainer (or unless your commit is still in "draft commit" stage). Lastly, make sure to comply with our AI Policy when using AI. Your pull request will be reviewed as soon as possible. |
|
Hello, thank you for your PR, since you mentioned Windows build issues, have you tried following: https://guide.riot-os.org/getting-started/install-wsl/? Also, I don't fully understand your testing instructions, whats the idea of the first command sequence and what am I expected to see after running the second command ( |
|
Thanks for checking. I have not rerun this through the WSL setup yet; the Windows note was meant to explain why I only ran local static checks in this checkout. I updated the Testing procedure to make the intent clearer:
|
|
Thank you for your response, can you somehow create a test example for this PR that shows when this bug occurs, it's hard to guess whether or not this fixes a real bug with no clear example of this occurring, checking the git diff is also not really a testing procedure 🤨 |
a2b200b to
60ac60f
Compare
|
I added a concrete regression example in The new step sends a Local checks I could run from this Windows checkout passed:
I still cannot run the full |
|
Due to how the GitHub review system works, please avoid force-pushing or squashing your commits unless asked to by a maintainer (or unless your commit is still in "draft commit" stage). Lastly, make sure to comply with our AI Policy when using AI. |
|
Also, what are those tests supposed to show me, I think this is the first time I have seen somebody use |
|
Thanks, that is fair feedback.
That step sends For the origin of the issue: I am not using emcute in a deployed project. I found it while auditing I also updated the PR description to make this clearer and to separate the real regression scenario from the local |
|
@Old-Ding: Can you provide a photo of your test setup and copy-paste the verbatim log output of the test? |
Contribution description
emcute_con()lockstxlockbefore checking the current gateway state and before running the optional last-will handshake. Several error paths returned after that lock was acquired without unlocking it.This fixes the connect error paths by unlocking
txlockbefore returning when:WILLTOPICREQfailsWILLMSGREQfailsThe change is intentionally limited to releasing the existing lock on paths that already return an error. It does not change MQTT-SN packet encoding or the existing client ID length validation.
Testing procedure
A regression scenario was added to
tests/net/emcute/tests-as-root/01-run.py.The new
check_will_topic_overflow_releases_txlock()step constructs a will topic that is one byte longer than the test'sCONFIG_EMCUTE_TOPIC_MAXLEN=249, then sends this shell command twice:Expected result with this fix: both attempts print
error: unable to connect to <gateway>and the test continues.Expected result before this fix: the first attempt reaches the
EMCUTE_OVERFLOWpath aftertxlockhas been acquired and returns without unlocking it, so the second attempt blocks waiting for the same lock. The repeated command is what turns the missing unlock into an observable test hang.The local checks I can run from this Windows checkout are only sanity checks for the patch and the modified Python test harness:
py_compileis not meant as behavioral validation for emcute; it only verifies that the edited Python test file still parses in this local environment.I still cannot run the full RIOT native build locally because this checkout has no
makeand no installed WSL distribution. With a RIOT build environment, the relevant target is:The PR Murdock run passed with 11124 successful jobs and 0 failures.
Issues/PRs references
None found.
Declaration of AI-Tools / LLMs usage:
AI-Tools / LLMs that were used are: