go/internal/jsonrpc2_v2
Bryan C. Mills 039b24b625 internal/jsonrpc2_v2: initiate shutdown when the Writer breaks
Prior to this CL we already shut down a jsonrpc2_v2.Conn when its
Reader breaks, which we expect to be the common shutdown path.
However, with certain kinds of connections (notably those over
stdin+stdout), it is possible for the Writer side to fail while
the Reader remains working.

If the Writer has failed, we have no way to return the required
Response messages for incoming calls, nor to write new Request
messages of our own. Since we have no way to return a response,
we will now mark those incoming calls as canceled.

However, even if the Writer has failed we may still be able to read
the responses for any outgoing calls that are already in flight. When
our in-flight calls complete, we could in theory even continue to
process Notification messages from the Reader; however, those are
unlikely to be useful with half the connection broken. It seems more
helpful — and less surprising — to go ahead and shut down the
connection completely when it becomes idle.

This is a redo of CL 446315, with additional fixes for bugs exposed on
the -race builders and some extra code cleanup from the process of
diagnosing those bugs.

Updates golang/go#46520.
Updates golang/go#49387.

Change-Id: I746409a7aa2c22d5651448ed0135b5ac21a9808e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/447035
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-11-02 21:32:11 +00:00
..
conn.go internal/jsonrpc2_v2: initiate shutdown when the Writer breaks 2022-11-02 21:32:11 +00:00
frame.go internal/jsonrpc2_v2: initiate shutdown when the Writer breaks 2022-11-02 21:32:11 +00:00
jsonrpc2.go internal/jsonrpc2_v2: add Func convenience wrappers for the Binder and Preempter interfaces 2022-10-18 21:38:33 +00:00
jsonrpc2_test.go internal/jsonrpc2_v2: rename Serve to NewServer and eliminate its error return 2022-10-31 15:32:39 +00:00
messages.go internal/jsonrpc2*: remove usage of golang.org/x/xerrors 2022-04-20 16:10:40 +00:00
net.go internal/jsonrpc2_v2: rework Connection concurrency 2022-10-31 15:02:00 +00:00
serve.go internal/jsonrpc2_v2: rename Serve to NewServer and eliminate its error return 2022-10-31 15:32:39 +00:00
serve_go116.go internal/jsonrpc2_v2: rework Connection concurrency 2022-10-31 15:02:00 +00:00
serve_pre116.go internal/jsonrpc2_v2: rework Connection concurrency 2022-10-31 15:02:00 +00:00
serve_test.go internal/jsonrpc2_v2: rename Serve to NewServer and eliminate its error return 2022-10-31 15:32:39 +00:00
wire.go internal/jsonrpc2_v2: rework concurrency in idleListener 2022-10-17 20:15:04 +00:00
wire_test.go internal/jsonrpc2_v2: an updated jsonrpc2 library 2021-03-24 21:26:20 +00:00