forked from TrueCloudLab/rclone
Fix uploading big files which was causing timeouts or panics
The symtom was one of these two on upload of files only
* panic: d.nx != 0 in crypto/md5.(*digest).checkSum
* read tcp: i/o timeout
It turned out to be a combination of two upstream bugs
* 5a2187309e
* https://groups.google.com/forum/#!topic/golang-dev/0Nl6k5Sj6UU
This commit contains a work-around for the second problem, I've fixed
the first and had the change accepted upstream.
This commit is contained in:
parent
97dced6a0b
commit
74994a2ec1
1 changed files with 10 additions and 0 deletions
|
@ -187,6 +187,12 @@ func (s *StatsInfo) DoneTransferring(o Object) {
|
||||||
|
|
||||||
// Account limits and accounts for one transfer
|
// Account limits and accounts for one transfer
|
||||||
type Account struct {
|
type Account struct {
|
||||||
|
// The mutex is to make sure Read() and Close() aren't called
|
||||||
|
// concurrently. Unfortunately the persistent connection loop
|
||||||
|
// in http transport calls Read() after Do() returns on
|
||||||
|
// CancelRequest so this race can happen when it apparently
|
||||||
|
// shouldn't.
|
||||||
|
mu sync.Mutex
|
||||||
in io.ReadCloser
|
in io.ReadCloser
|
||||||
bytes int64
|
bytes int64
|
||||||
}
|
}
|
||||||
|
@ -200,6 +206,8 @@ func NewAccount(in io.ReadCloser) *Account {
|
||||||
|
|
||||||
// Read bytes from the object - see io.Reader
|
// Read bytes from the object - see io.Reader
|
||||||
func (file *Account) Read(p []byte) (n int, err error) {
|
func (file *Account) Read(p []byte) (n int, err error) {
|
||||||
|
file.mu.Lock()
|
||||||
|
defer file.mu.Unlock()
|
||||||
n, err = file.in.Read(p)
|
n, err = file.in.Read(p)
|
||||||
file.bytes += int64(n)
|
file.bytes += int64(n)
|
||||||
Stats.Bytes(int64(n))
|
Stats.Bytes(int64(n))
|
||||||
|
@ -215,6 +223,8 @@ func (file *Account) Read(p []byte) (n int, err error) {
|
||||||
|
|
||||||
// Close the object
|
// Close the object
|
||||||
func (file *Account) Close() error {
|
func (file *Account) Close() error {
|
||||||
|
file.mu.Lock()
|
||||||
|
defer file.mu.Unlock()
|
||||||
// FIXME do something?
|
// FIXME do something?
|
||||||
return file.in.Close()
|
return file.in.Close()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue