Swap to net.ErrClosed checks for services

In Go 1.16 `net.ErrClosed` was exported, removing the need to check the
exact text of "use of closed network connection". The stdlib's net listeners
are all setup for this to be a reality, but on Windows containerd uses the
the go-winio projects named pipe implementation as the listener for services.
Before version 0.6.0 this project returned a different error named
`ErrPipeListenerClosed` for using a closed pipe, where this error was just
an `errors.New` with the same text as `net.ErrClosed`, so checking against
`net.ErrClosed` wasn't possible.

Starting in 0.6.0 go-winio has that error assigned to `net.ErrClosed` directly
so this *should* be alright to finally change.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
This commit is contained in:
Daniel Canter
2022-09-28 17:59:11 -07:00
parent 7374e0a330
commit 4333e6a6d6
3 changed files with 5 additions and 10 deletions

View File

@@ -30,7 +30,6 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
@@ -473,10 +472,7 @@ func (pc *proxyClients) getClient(address string) (*grpc.ClientConn, error) {
}
func trapClosedConnErr(err error) error {
if err == nil {
return nil
}
if strings.Contains(err.Error(), "use of closed network connection") {
if err == nil || errors.Is(err, net.ErrClosed) {
return nil
}
return err