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

fix: stop OperationHandler spawning extra tasks #3046

Merged

Conversation

Bravo555
Copy link
Contributor

@Bravo555 Bravo555 commented Aug 1, 2024

Proposed changes

When receiving multiple MQTT messages on a command topic, OperationHandler::handle method spawned extra tokio tasks, because .unwrap_or and not .unwrap_or_else was used when checking if a task for that topic already existed. Fortunately because returned object, and along it the sender to the task, was immediately dropped, the task exited and so we weren't leaking anything.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue


Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

When receiving multiple MQTT messages on a command topic,
`OperationHandler::handle` method spawned extra tokio tasks, because
`.unwrap_or` and not `.unwrap_or_else` was used when checking if a task
for that topic already existed. Fortunately because returned object, and
along it the sender to the task, was immediately dropped, the task
exited and so we weren't leaking anything.

Signed-off-by: Marcel Guzik <[email protected]>
Copy link

codecov bot commented Aug 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.0%. Comparing base (b79f03a) to head (be3b850).
Report is 88 commits behind head on main.

Additional details and impacted files
Files Coverage Δ
...xtensions/c8y_mapper_ext/src/operations/handler.rs 95.5% <100.0%> (ø)

... and 2 files with indirect coverage changes

Copy link
Contributor

github-actions bot commented Aug 1, 2024

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
491 0 2 491 100 1h21m53.26477s

@reubenmiller reubenmiller enabled auto-merge August 1, 2024 17:37
Copy link
Contributor

@reubenmiller reubenmiller left a comment

Choose a reason for hiding this comment

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

Approved (after verifying the Rust docs)

@reubenmiller reubenmiller added this pull request to the merge queue Aug 1, 2024
Merged via the queue into thin-edge:main with commit 28a6221 Aug 1, 2024
33 checks passed
@reubenmiller reubenmiller added the theme:mqtt Theme: mqtt and mosquitto related topics label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:mqtt Theme: mqtt and mosquitto related topics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants