Skip to content

Pluggable monitor fix and refactor #1482

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

Merged
merged 6 commits into from
Oct 1, 2021

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Sep 30, 2021

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce?
    Fixed a race condition in the pluggable monitor client due to a stateLock contention:

    1. many methods (for example Close) had the stateLock held for the entire scope of the function
    2. at the same time, the "port_closed" message can be received at any moment in the decode loop, and it requires a stateLock as well, but it may be blocked until the Close function get the close message (that may happen later in the decodeLoop)

    In this case the worst case scenario is that the decode loop is blocked for 10 seconds until the timeout occurs and Close exits, but this is not ideal. This bug has been fixed by removing the state from the pluggable monitor client, since it's not really useful in any case.

  • Other information:
    Some other refactorings have been made in the same PR to simplify and make error handling and logging more coherent.

Many methods had the stateLock held for the entire scope of the function
call but the 'port_closed' message can be received at any moment,
asyncronously, and it requires a stateLock as well. In this case the
worst case is that the decode loop is blocked for 10 seconds until the
timeout occurs, but this is not ideal.

This bug has been fixed by removing the state, since it's not really
useful.
@cmaglie cmaglie merged commit 9079f85 into arduino:master Oct 1, 2021
@cmaglie cmaglie deleted the pluggable_monitor_fix_and_refactor branch October 1, 2021 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants