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

Fix a missing s.lock.Unlock() on an error path #2643

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Nov 26, 2024

... and use defer to avoid that bug in the future.

(Split from larger work as an independent piece. Reviewing is easier when ignoring whitespace changes.)

@mtrmac mtrmac added the kind/bug A defect in an existing functionality (or a PR fixing it) label Nov 26, 2024
if uncompressedDigest := options.Cache.UncompressedDigestForTOC(out.TOCDigest); uncompressedDigest != "" {
s.lockProtected.indexToDiffID[options.LayerIndex] = uncompressedDigest
if err := func() error { // A scope for defer
s.lock.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this have a defer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh wow, that’s embarrassing. 🤦

Thanks!

... and use defer to avoid that bug in the future.

Signed-off-by: Miloslav Trmač <[email protected]>
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A defect in an existing functionality (or a PR fixing it)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants