Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: Ensure GRPCServer GracefulStop() and Stop() call GRPCBroker C…
…lose() (#220) Initializing a `GRPCServer` will do the following: ```go // Register the broker service brokerServer := newGRPCBrokerServer() plugin.RegisterGRPCBrokerServer(s.server, brokerServer) s.broker = newGRPCBroker(brokerServer, s.TLS) go s.broker.Run() ``` While the current `GracefulStop()` and `Stop()` methods omit any handling of the underlying `s.broker`, which means the broker goroutine will leak: ```text [Goroutine 53 in state select, with github.com/hashicorp/go-plugin.(*gRPCBrokerServer).Recv on top of the stack: goroutine 53 [select]: github.com/hashicorp/go-plugin.(*gRPCBrokerServer).Recv(0x29?) /Users/bflad/go/pkg/mod/github.com/hashicorp/go-plugin@v1.4.4/grpc_broker.go:121 +0x58 github.com/hashicorp/go-plugin.(*GRPCBroker).Run(0x140003ca190) /Users/bflad/go/pkg/mod/github.com/hashicorp/go-plugin@v1.4.4/grpc_broker.go:411 +0x40 created by github.com/hashicorp/go-plugin.(*GRPCServer).Init /Users/bflad/go/pkg/mod/github.com/hashicorp/go-plugin@v1.4.4/grpc_server.go:85 +0x424 ] ``` This change will now call the `Close()` method on the broker and set it to `nil` when `GracefulStop()` or `Stop()` is called on the server itself.
- Loading branch information