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>
diff --git a/internal/jsonrpc2_v2/serve.go b/internal/jsonrpc2_v2/serve.go
index 20cc378..f3b78f5 100644
--- a/internal/jsonrpc2_v2/serve.go
+++ b/internal/jsonrpc2_v2/serve.go
@@ -7,7 +7,10 @@
import (
"context"
"io"
+ "runtime"
+ "strings"
"sync"
+ "syscall"
"time"
errors "golang.org/x/xerrors"
@@ -155,6 +158,16 @@
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
}