|
@@ -27,6 +27,7 @@ import (
|
|
|
"net"
|
|
"net"
|
|
|
"os"
|
|
"os"
|
|
|
"path/filepath"
|
|
"path/filepath"
|
|
|
|
|
+ "strings"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/coreos/etcd/pkg/tlsutil"
|
|
"github.com/coreos/etcd/pkg/tlsutil"
|
|
@@ -269,3 +270,12 @@ func ShallowCopyTLSConfig(cfg *tls.Config) *tls.Config {
|
|
|
}
|
|
}
|
|
|
return &ncfg
|
|
return &ncfg
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// IsClosedConnError returns true if the error is from closing listener, cmux.
|
|
|
|
|
+// copied from golang.org/x/net/http2/http2.go
|
|
|
|
|
+func IsClosedConnError(err error) bool {
|
|
|
|
|
+ // 'use of closed network connection' (Go <=1.8)
|
|
|
|
|
+ // 'use of closed file or network connection' (Go >1.8, internal/poll.ErrClosing)
|
|
|
|
|
+ // 'mux: listener closed' (cmux.ErrListenerClosed)
|
|
|
|
|
+ return err != nil && strings.Contains(err.Error(), "closed")
|
|
|
|
|
+}
|