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