internal/jsonrpc2_v2: make TestIdleTimeout pass on Plan 9

Fixes golang/go#46175

Change-Id: I9c801ff42392dbff2fcb74dea7549d849c7e3624
Reviewed-on: https://go-review.googlesource.com/c/tools/+/323529
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Fazlul Shahriar 2021-05-28 23:57:42 -04:00 • committed by Bryan C. Mills
commit facfa16e73

View file

@ -7,7 +7,10 @@ package jsonrpc2
import (
"context"
"io"
"runtime"
"strings"
"sync"
"syscall"
"time"
errors "golang.org/x/xerrors"
@ -155,6 +158,16 @@ func isClosingError(err error) bool {
return true
}
if runtime.GOOS == "plan9" {
// Error reading from a closed connection.
if err == syscall.EINVAL {
return true
}
// Error trying to accept a new connection from a closed listener.
if strings.HasSuffix(err.Error(), " listen hungup") {
return true
}
}
return false
}