TUN-5142: defer close rpcconn inside unregister instead of ServeControlStream

This commit is contained in:
Sudarsan Reddy 2021-09-24 12:56:31 +01:00
parent 27e1277a3b
commit d7da74cb9e
1 changed files with 2 additions and 1 deletions

View File

@ -64,9 +64,9 @@ func (c *controlStream) ServeControlStream(
shouldWaitForUnregister bool,
) error {
rpcClient := c.newRPCClientFunc(ctx, rw, c.observer.log)
defer rpcClient.Close()
if err := rpcClient.RegisterConnection(ctx, c.namedTunnelConfig, connOptions, c.connIndex, c.observer); err != nil {
rpcClient.Close()
return err
}
c.connectedFuse.Connected()
@ -82,6 +82,7 @@ func (c *controlStream) ServeControlStream(
func (c *controlStream) waitForUnregister(ctx context.Context, rpcClient NamedTunnelRPCClient) {
// wait for connection termination or start of graceful shutdown
defer rpcClient.Close()
select {
case <-ctx.Done():
break