]> Sergey Matveev's repositories - btrtrc.git/blobdiff - reader.go
Replacing pendingWrites WaitGroup with Mutex/Cond/int
[btrtrc.git] / reader.go
index c9a0675eb21cf910ac24ef1c9c8695e978efb41a..32dae43270c9fce90988535d55f9a12d395d4e1b 100644 (file)
--- a/reader.go
+++ b/reader.go
@@ -128,7 +128,11 @@ again:
        if int64(len(b1)) > ip.Length()-po {
                b1 = b1[:ip.Length()-po]
        }
-       tp.pendingWrites.Wait()
+       tp.pendingWritesMutex.Lock()
+       for tp.pendingWrites != 0 {
+               tp.noPendingWrites.Wait()
+       }
+       tp.pendingWritesMutex.Unlock()
        n, err = dataReadAt(r.t.data, b1, pos)
        if n != 0 {
                err = nil