From facfa16e733ac1d1cbee9f4146afa16f0ee5b5e7 Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Fri, 28 May 2021 23:57:42 -0400 Subject: [PATCH] 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 Reviewed-by: Ian Cottrell Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills gopls-CI: kokoro --- internal/jsonrpc2/serve.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/jsonrpc2/serve.go b/internal/jsonrpc2/serve.go index ba1db52..04a6be5 100644 --- a/internal/jsonrpc2/serve.go +++ b/internal/jsonrpc2/serve.go @@ -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 }