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

ipcache is not fully threadsafe #30

Open
pboothe opened this issue Oct 18, 2019 · 1 comment
Open

ipcache is not fully threadsafe #30

pboothe opened this issue Oct 18, 2019 · 1 comment
Assignees
Labels
backlog bug Something isn't working P1

Comments

@pboothe
Copy link
Contributor

pboothe commented Oct 18, 2019

It is designed to be used like:

if !cache.Has(ip) {
  cache.Add(ip)
  Trace(ip)
}

but this check-then-add pattern is not threadsafe. Instead, we should use an unconditional Add that returns true if the item was not previously in the cache. Then the usage would be:

if cache.Add(ip) {
  Trace(ip)
}

which (as long as Add is mutex-protected) is threadsafe.

@pboothe
Copy link
Contributor Author

pboothe commented Oct 18, 2019

Ya, I assigned this one to you because you will be moving the location of the cache around already, so it seems like a small bug to fix as part of that work.

@pboothe pboothe added bug Something isn't working P1 backlog and removed review/triage labels Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog bug Something isn't working P1
Projects
None yet
Development

No branches or pull requests

2 participants