awslabs / aws-c-mqtt

C99 implementation of the MQTT 3.1.1 specification.
Apache License 2.0
93 stars 29 forks source link

Fix a bug when unsub from a non-subscribed parent topic #297

Closed xiazhvera closed 1 year ago

xiazhvera commented 1 year ago

Issue #, if available: https://github.com/awslabs/aws-crt-nodejs/issues/405

Description of changes: The issue happens when the application tries to unsubscribe from a non-subscribed parent topic. As an example:

Subscribe(test/topic/child)
Unsubscribe(test/topic)

As the "test/topic" is never subscribed, the topic tree would not delete the topic. However, topic tree would treat the topic as "deleted" and tries to update the underlying topic filter, which hits the assertion. Fixed it by validating if the topic is deleted before proceed to next step.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (a760f42) 80.34% compared to head (da001a3) 80.34%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #297 +/- ## ======================================= Coverage 80.34% 80.34% ======================================= Files 18 18 Lines 7571 7571 ======================================= Hits 6083 6083 Misses 1488 1488 ``` | [Impacted Files](https://app.codecov.io/gh/awslabs/aws-c-mqtt/pull/297?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=awslabs) | Coverage Δ | | |---|---|---| | [source/topic\_tree.c](https://app.codecov.io/gh/awslabs/aws-c-mqtt/pull/297?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=awslabs#diff-c291cmNlL3RvcGljX3RyZWUuYw==) | `89.51% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.