TUN-5142: defer close rpcconn inside unregister instead of ServeControlStream
This commit is contained in:
parent
27e1277a3b
commit
d7da74cb9e
|
@ -64,9 +64,9 @@ func (c *controlStream) ServeControlStream(
|
||||||
shouldWaitForUnregister bool,
|
shouldWaitForUnregister bool,
|
||||||
) error {
|
) error {
|
||||||
rpcClient := c.newRPCClientFunc(ctx, rw, c.observer.log)
|
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 {
|
if err := rpcClient.RegisterConnection(ctx, c.namedTunnelConfig, connOptions, c.connIndex, c.observer); err != nil {
|
||||||
|
rpcClient.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c.connectedFuse.Connected()
|
c.connectedFuse.Connected()
|
||||||
|
@ -82,6 +82,7 @@ func (c *controlStream) ServeControlStream(
|
||||||
|
|
||||||
func (c *controlStream) waitForUnregister(ctx context.Context, rpcClient NamedTunnelRPCClient) {
|
func (c *controlStream) waitForUnregister(ctx context.Context, rpcClient NamedTunnelRPCClient) {
|
||||||
// wait for connection termination or start of graceful shutdown
|
// wait for connection termination or start of graceful shutdown
|
||||||
|
defer rpcClient.Close()
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue