1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 10:33:34 +00:00

Retry errors which indicate the connection closed prematurely.

See discussion in #442
This commit is contained in:
Nick Craig-Wood
2016-04-29 16:42:08 +01:00
parent 5c2d8ffe33
commit 1752ee3c8b
4 changed files with 64 additions and 4 deletions

27
fs/closed_conn_win.go Normal file
View File

@@ -0,0 +1,27 @@
// +build windows
package fs
import (
"net"
"os"
"syscall"
)
// isClosedConnErrorPlatform reports whether err is an error from use
// of a closed network connection using platform specific error codes.
//
// Code adapted from net/http
func isClosedConnErrorPlatform(err error) bool {
if oe, ok := err.(*net.OpError); ok && oe.Op == "read" {
if se, ok := oe.Err.(*os.SyscallError); ok && se.Syscall == "wsarecv" {
if errno, ok := se.Err.(syscall.Errno); ok {
const WSAECONNABORTED syscall.Errno = 10053
if errno == syscall.WSAECONNRESET || errno == WSAECONNABORTED {
return true
}
}
}
}
return false
}