vendor: update github.com/ncw/swift to fix memory leak in swift transfers

This commit is contained in:
Nick Craig-Wood 2017-10-19 14:44:13 +01:00
parent 115053930e
commit 567071750b
5 changed files with 15 additions and 8 deletions

6
Gopkg.lock generated
View file

@ -136,7 +136,7 @@
branch = "master" branch = "master"
name = "github.com/ncw/swift" name = "github.com/ncw/swift"
packages = ["."] packages = ["."]
revision = "9d3f812e23d270d1c66a9a01e20af1005061cdc4" revision = "c95c6e5c2d1a3d37fc44c8c6dc9e231c7500667d"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -157,10 +157,10 @@
revision = "2b3a18b5f0fb6b4f9190549597d3f962c02bc5eb" revision = "2b3a18b5f0fb6b4f9190549597d3f962c02bc5eb"
[[projects]] [[projects]]
branch = "master"
name = "github.com/pkg/sftp" name = "github.com/pkg/sftp"
packages = ["."] packages = ["."]
revision = "98203f5a8333288eb3163b7c667d4260fe1333e9" revision = "7c1f7a370726a2457b33b29baefc2402b4965c65"
version = "1.0.0"
[[projects]] [[projects]]
name = "github.com/pmezard/go-difflib" name = "github.com/pmezard/go-difflib"

View file

@ -276,8 +276,9 @@ func (file *largeObjectCreateFile) Size() int64 {
} }
func withLORetry(expectedSize int64, fn func() (Headers, int64, error)) (err error) { func withLORetry(expectedSize int64, fn func() (Headers, int64, error)) (err error) {
endTimer := time.NewTimer(readAfterWriteTimeout)
defer endTimer.Stop()
waitingTime := readAfterWriteWait waitingTime := readAfterWriteWait
endTimer := time.After(readAfterWriteTimeout)
for { for {
var headers Headers var headers Headers
var sz int64 var sz int64
@ -288,11 +289,13 @@ func withLORetry(expectedSize int64, fn func() (Headers, int64, error)) (err err
} else { } else {
return return
} }
waitTimer := time.NewTimer(waitingTime)
select { select {
case <-endTimer: case <-endTimer.C:
waitTimer.Stop()
err = fmt.Errorf("Timeout expired while waiting for object to have size == %d, got: %d", expectedSize, sz) err = fmt.Errorf("Timeout expired while waiting for object to have size == %d, got: %d", expectedSize, sz)
return return
case <-time.After(waitingTime): case <-waitTimer.C:
waitingTime *= 2 waitingTime *= 2
} }
} }

View file

@ -471,6 +471,7 @@ again:
} }
if req != nil { if req != nil {
timer := time.NewTimer(c.ConnectTimeout) timer := time.NewTimer(c.ConnectTimeout)
defer timer.Stop()
var resp *http.Response var resp *http.Response
resp, err = c.doTimeoutRequest(timer, req) resp, err = c.doTimeoutRequest(timer, req)
if err != nil { if err != nil {
@ -691,6 +692,7 @@ func (c *Connection) Call(targetUrl string, p RequestOpts) (resp *http.Response,
URL.RawQuery = p.Parameters.Encode() URL.RawQuery = p.Parameters.Encode()
} }
timer := time.NewTimer(c.ConnectTimeout) timer := time.NewTimer(c.ConnectTimeout)
defer timer.Stop()
reader := p.Body reader := p.Body
if reader != nil { if reader != nil {
reader = newWatchdogReader(reader, c.Timeout, timer) reader = newWatchdogReader(reader, c.Timeout, timer)

View file

@ -38,10 +38,12 @@ func (t *timeoutReader) Read(p []byte) (int, error) {
done <- result{n, err} done <- result{n, err}
}() }()
// Wait for the read or the timeout // Wait for the read or the timeout
timer := time.NewTimer(t.timeout)
defer timer.Stop()
select { select {
case r := <-done: case r := <-done:
return r.n, r.err return r.n, r.err
case <-time.After(t.timeout): case <-timer.C:
t.cancel() t.cancel()
return 0, TimeoutError return 0, TimeoutError
} }

2
vendor/github.com/pkg/sftp/sftp.go generated vendored
View file

@ -1,5 +1,5 @@
// Package sftp implements the SSH File Transfer Protocol as described in // Package sftp implements the SSH File Transfer Protocol as described in
// https://filezilla-project.org/specs/draft-ietf-secsh-filexfer-02.txt // https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02
package sftp package sftp
import ( import (