Skip to content

Commit d7da74c

Browse files
TUN-5142: defer close rpcconn inside unregister instead of ServeControlStream
1 parent 27e1277 commit d7da74c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

connection/control.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ func (c *controlStream) ServeControlStream(
6464
shouldWaitForUnregister bool,
6565
) error {
6666
rpcClient := c.newRPCClientFunc(ctx, rw, c.observer.log)
67-
defer rpcClient.Close()
6867

6968
if err := rpcClient.RegisterConnection(ctx, c.namedTunnelConfig, connOptions, c.connIndex, c.observer); err != nil {
69+
rpcClient.Close()
7070
return err
7171
}
7272
c.connectedFuse.Connected()
@@ -82,6 +82,7 @@ func (c *controlStream) ServeControlStream(
8282

8383
func (c *controlStream) waitForUnregister(ctx context.Context, rpcClient NamedTunnelRPCClient) {
8484
// wait for connection termination or start of graceful shutdown
85+
defer rpcClient.Close()
8586
select {
8687
case <-ctx.Done():
8788
break

0 commit comments

Comments
 (0)