-
Notifications
You must be signed in to change notification settings - Fork 515
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
mem/file.go - Fix some races in accessing fields of FileData #134
Conversation
mem/file.go
Outdated
f.name = newname | ||
} | ||
|
||
func SetMode(f *FileData, mode os.FileMode) { | ||
f.Lock() | ||
defer f.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use defer
when the method is so short.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it would be great if you added a test that demonstrates this problem.
@bep thanks for the review and sorry for the delay addressing them. I also enabled Now I realize I should maybe have added it in the main |
* Splitting SetModeTime to avoid double locking * Adding locks all over the place.
I verified that the new tests fail with data races without this patch. |
Fixes #133 |
Potential fix for #133