Skip to content

Commit

Permalink
add err for read fail count
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerinthenight committed Jul 10, 2024
1 parent 21f751d commit c54b5c4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion distmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func (r *Reader) Read(out chan []byte) {

defer ra.Close()
var off int64
var count int
var count, fails int
for _, loc := range r.dm.dlocs {
b := make([]byte, loc)
n, err := ra.ReadAt(b, off)
Expand All @@ -398,11 +398,21 @@ func (r *Reader) Read(out chan []byte) {
r.Unlock()
}

if loc != n {
fails++
}

_ = n
out <- b
off = off + int64(off)
count++
}

if fails > 0 {
r.Lock()
r.err = fmt.Errorf("ReadAt failed %v times", fails)
r.Unlock()
}
}()
}
}
Expand Down

0 comments on commit c54b5c4

Please sign in to comment.