mirror of
https://github.com/rclone/rclone.git
synced 2024-11-23 00:43:49 +01:00
Unwrap errors properly for patform specific connection retry code.
Include more possible errors for Windows. For #442
This commit is contained in:
parent
661715733a
commit
7fe653c350
@ -16,8 +16,15 @@ func isClosedConnErrorPlatform(err error) bool {
|
|||||||
if oe, ok := err.(*net.OpError); ok {
|
if oe, ok := err.(*net.OpError); ok {
|
||||||
if se, ok := oe.Err.(*os.SyscallError); ok {
|
if se, ok := oe.Err.(*os.SyscallError); ok {
|
||||||
if errno, ok := se.Err.(syscall.Errno); ok {
|
if errno, ok := se.Err.(syscall.Errno); ok {
|
||||||
const WSAECONNABORTED syscall.Errno = 10053
|
const (
|
||||||
if errno == syscall.WSAECONNRESET || errno == WSAECONNABORTED {
|
WSAECONNABORTED syscall.Errno = 10053
|
||||||
|
WSAHOST_NOT_FOUND syscall.Errno = 11001
|
||||||
|
WSATRY_AGAIN syscall.Errno = 11002
|
||||||
|
WSAENETRESET syscall.Errno = 10052
|
||||||
|
WSAETIMEDOUT syscall.Errno = 10060
|
||||||
|
)
|
||||||
|
switch errno {
|
||||||
|
case syscall.WSAECONNRESET, WSAECONNABORTED, WSAHOST_NOT_FOUND, WSATRY_AGAIN, WSAENETRESET, WSAETIMEDOUT:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
fs/error.go
13
fs/error.go
@ -8,6 +8,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Retry is an optional interface for error as to whether the
|
// Retry is an optional interface for error as to whether the
|
||||||
@ -95,16 +97,19 @@ func ShouldRetry(err error) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for premature closing of connection
|
// Find root cause if available
|
||||||
if err == io.EOF || err == io.ErrUnexpectedEOF || isClosedConnError(err) {
|
err = errors.Cause(err)
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unwrap url.Error
|
// Unwrap url.Error
|
||||||
if urlErr, ok := err.(*url.Error); ok {
|
if urlErr, ok := err.(*url.Error); ok {
|
||||||
err = urlErr.Err
|
err = urlErr.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Look for premature closing of connection
|
||||||
|
if err == io.EOF || err == io.ErrUnexpectedEOF || isClosedConnError(err) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Check for net error Timeout()
|
// Check for net error Timeout()
|
||||||
if x, ok := err.(interface {
|
if x, ok := err.(interface {
|
||||||
Timeout() bool
|
Timeout() bool
|
||||||
|
Loading…
Reference in New Issue
Block a user