mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
Make IsConnectionReset work with more error implementations.
This commit is contained in:
parent
a8a418b0ae
commit
313128d760
@ -18,6 +18,8 @@ package net
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
@ -38,8 +40,16 @@ func IPNetEqual(ipnet1, ipnet2 *net.IPNet) bool {
|
|||||||
|
|
||||||
// Returns if the given err is "connection reset by peer" error.
|
// Returns if the given err is "connection reset by peer" error.
|
||||||
func IsConnectionReset(err error) bool {
|
func IsConnectionReset(err error) bool {
|
||||||
opErr, ok := err.(*net.OpError)
|
if urlErr, ok := err.(*url.Error); ok {
|
||||||
if ok && opErr.Err.Error() == syscall.ECONNRESET.Error() {
|
err = urlErr.Err
|
||||||
|
}
|
||||||
|
if opErr, ok := err.(*net.OpError); ok {
|
||||||
|
err = opErr.Err
|
||||||
|
}
|
||||||
|
if osErr, ok := err.(*os.SyscallError); ok {
|
||||||
|
err = osErr.Err
|
||||||
|
}
|
||||||
|
if errno, ok := err.(syscall.Errno); ok && errno == syscall.ECONNRESET {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user