internal/jsonrpc2_v2: initialize async before binding
The lsprpc package needs to wait on the newly bound connection to perform some tear-down, so it must be safe to call conn.Wait from Bind. Achieve this by switching async from an init pattern to a constructor. This means moving async fields to pointers, but since they weren't safe to use prior to initialization anyway this feels correct. Change-Id: I4f93980915e0b568fbf2db3cd7d062adf06e4b99 Reviewed-on: https://go-review.googlesource.com/c/tools/+/330929 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
parent
facfa16e73
commit
0c89f898b7
1 changed files with 7 additions and 5 deletions
|
|
@ -42,7 +42,7 @@ type Dialer interface {
|
|||
type Server struct {
|
||||
listener Listener
|
||||
binder Binder
|
||||
async async
|
||||
async *async
|
||||
}
|
||||
|
||||
// Dial uses the dialer to make a new connection, wraps the returned
|
||||
|
|
@ -68,8 +68,8 @@ func Serve(ctx context.Context, listener Listener, binder Binder) (*Server, erro
|
|||
server := &Server{
|
||||
listener: listener,
|
||||
binder: binder,
|
||||
async: newAsync(),
|
||||
}
|
||||
server.async.init()
|
||||
go server.run(ctx)
|
||||
return server, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue