awslabs / aws-c-mqtt

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

Move acquire/release to the connection vtable #285

Closed bretambrose closed 1 year ago

bretambrose commented 1 year ago

The adapter's shutdown process needs to support additional logic within the scope of the state lock when the decision to shutdown is made (ref count zero). The simple ref count object in common cannot support this (atomic integers are insufficient), so we do the ref count by hand in the adapter so that we can disable the adapter inside the lock in one atomic action.

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: 80.64% and no project coverage change.

Comparison is base (4885afb) 81.17% compared to head (bb1013d) 81.18%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #285 +/- ## ======================================= Coverage 81.17% 81.18% ======================================= Files 18 18 Lines 7311 7322 +11 ======================================= + Hits 5935 5944 +9 - Misses 1376 1378 +2 ``` | [Impacted Files](https://app.codecov.io/gh/awslabs/aws-c-mqtt/pull/285?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=awslabs) | Coverage Δ | | |---|---|---| | [source/mqtt3\_to\_mqtt5\_adapter.c](https://app.codecov.io/gh/awslabs/aws-c-mqtt/pull/285?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=awslabs#diff-c291cmNlL21xdHQzX3RvX21xdHQ1X2FkYXB0ZXIuYw==) | `76.19% <72.72%> (-2.19%)` | :arrow_down: | | [source/client.c](https://app.codecov.io/gh/awslabs/aws-c-mqtt/pull/285?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=awslabs#diff-c291cmNlL2NsaWVudC5j) | `65.46% <100.00%> (+0.17%)` | :arrow_up: | | [source/client\_impl\_shared.c](https://app.codecov.io/gh/awslabs/aws-c-mqtt/pull/285?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=awslabs#diff-c291cmNlL2NsaWVudF9pbXBsX3NoYXJlZC5j) | `77.27% <100.00%> (-0.51%)` | :arrow_down: |

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