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

Add missing mutex lock #5

Merged
merged 1 commit into from
Sep 13, 2022
Merged

Conversation

jacobvosmaer
Copy link
Contributor

The functions *Sentinel.putToTop and *Sentinel.putToBottom are meant to be called with the *Sentinel.mu mutex held. However, putToTop was being called without holding the mutex. This commit moves the locking/unlocking into the helper functions so that the caller cannot forget to lock.

While we are here, we simplify the helper functions.

The functions *Sentinel.putToTop and *Sentinel.putToBottom were meant
to be called with the *Sentinel.mu mutex held. However, putToTop was
being called _without_ holding the mutex. This commit moves the
locking/unlocking into the helper functions so that the caller cannot
forget to lock.

While we are here, we simplify the helper functions.
s.putToBottom(addr)
s.mu.Unlock()
continue
}
s.putToTop(addr)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the only call site of putToTop and as you can see, we don't hold the mutex when calling it.

@FZambia
Copy link
Owner

FZambia commented Sep 13, 2022

Hello @jacobvosmaer, many thanks!

@FZambia FZambia merged commit 9e2b40e into FZambia:master Sep 13, 2022
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