Skip to content

fix(lib/contracts): add mutex to caches #2140

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 1 commit into from
Oct 10, 2024
Merged

fix(lib/contracts): add mutex to caches #2140

merged 1 commit into from
Oct 10, 2024

Conversation

kevinhalliday
Copy link
Contributor

Add mutex to caches.

issue: none

var (
// cached addresses by network.
addrsCache = map[netconf.ID]Addresses{}
addrsCache = cache[map[netconf.ID]Addresses]{
mu: sync.Mutex{},
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to initialize it, empty value is fine

Suggested change
mu: sync.Mutex{},

@kevinhalliday kevinhalliday merged commit 28335e8 into main Oct 10, 2024
18 checks passed
@kevinhalliday kevinhalliday deleted the kh/fix-caches branch October 10, 2024 19:45
chmllr added a commit that referenced this pull request Oct 14, 2024
The PR #2140 introduced a
locking around a cache. Some parts of the critical section seem
unrelated to the locking and can be done before without changing the
read semantics (because this check happened after the cache read
before).

issue: none
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