2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-01 16:40:50 +00:00

Merge pull request #552 from benagricola/fix-connection-leak

Explicitly Close() obj after ReadFull()
This commit is contained in:
Alexander Neumann 2016-07-29 20:28:22 +02:00
commit a9729eeb1b

View File

@ -97,7 +97,17 @@ func (be s3) Load(h backend.Handle, p []byte, off int64) (int, error) {
defer func() {
be.connChan <- struct{}{}
}()
return io.ReadFull(obj, p)
// This may not read the whole object, so ensure object
// is closed to avoid duplicate connections.
n, err := io.ReadFull(obj, p)
if err != nil {
obj.Close()
} else {
err = obj.Close()
}
return n, err
}
// Save stores data in the backend at the handle.