mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-10 03:51:20 +00:00
Fix race condition
This commit is contained in:
parent
2a306419c8
commit
63186e34b3
@ -100,6 +100,9 @@ func (af *AutoFile) Write(b []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
func (af *AutoFile) Sync() error {
|
||||
af.mtx.Lock()
|
||||
defer af.mtx.Unlock()
|
||||
|
||||
return af.file.Sync()
|
||||
}
|
||||
|
||||
@ -115,6 +118,7 @@ func (af *AutoFile) openFile() error {
|
||||
func (af *AutoFile) Size() (int64, error) {
|
||||
af.mtx.Lock()
|
||||
defer af.mtx.Unlock()
|
||||
|
||||
if af.file == nil {
|
||||
err := af.openFile()
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user