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 bug: use defer to avoid potential lock leaking #34

Merged
merged 2 commits into from
Aug 25, 2021
Merged

fix bug: use defer to avoid potential lock leaking #34

merged 2 commits into from
Aug 25, 2021

Conversation

sillykelvin
Copy link
Contributor

This PR fixes issue #33.

writer.go Outdated
@@ -327,7 +328,6 @@ func (w *LockedWriter) Write(b []byte) (n int, err error) {
}

n, err = w.file.Write(b)
w.Unlock()
Copy link
Owner

Choose a reason for hiding this comment

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

Good catch.

But, defer will add extra cost.
could you please just add w.Unlock() after line 321?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done~

Copy link
Owner

@arthurkiller arthurkiller left a comment

Choose a reason for hiding this comment

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

LGTM

@arthurkiller arthurkiller merged commit 0207006 into arthurkiller:master Aug 25, 2021
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