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

config: protect global configOpts with a mutex #296

Merged
merged 1 commit into from
Mar 17, 2025

Conversation

mauri870
Copy link
Member

@mauri870 mauri870 commented Mar 17, 2025

There is a race condition in configOpts when one goroutine calls OverwriteConfigOpts while another reads the variable. This is common, as almost every method in config.C reads this global variable.

Fix the data race by using a mutex. Since this variable is mostly read, optimize it with a sync.RWMutex.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works

Related issues

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
bagder Daniel Stenberg
There is a race condition in configOpts when one goroutine calls
OverwriteConfigOpts while another reads the variable. This is common, as
almost every method in config.C reads this global variable.

Fix the data race by using a mutex. Since this variable is mostly read,
optimize it with a sync.RWMutex.
@mauri870 mauri870 added bug Something isn't working Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team labels Mar 17, 2025
@mauri870 mauri870 self-assigned this Mar 17, 2025
@mauri870 mauri870 requested a review from a team as a code owner March 17, 2025 16:36
@mauri870 mauri870 requested review from belimawr and rdner and removed request for a team March 17, 2025 16:36
@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

cc @mauri870

Copy link
Contributor

@leehinman leehinman left a comment

Choose a reason for hiding this comment

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

Thank You

@mauri870 mauri870 merged commit 9948f69 into elastic:main Mar 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants