File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -437,6 +437,14 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
437
437
logger .Debug (ctx , "accept pty failed" , slog .Error (err ))
438
438
return
439
439
}
440
+ closed := make (chan struct {})
441
+ _ = a .trackConnGoroutine (func () {
442
+ select {
443
+ case <- network .Closed ():
444
+ case <- closed :
445
+ }
446
+ _ = conn .Close ()
447
+ })
440
448
// This cannot use a JSON decoder, since that can
441
449
// buffer additional data that is required for the PTY.
442
450
rawLen := make ([]byte , 2 )
@@ -455,9 +463,10 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
455
463
if err != nil {
456
464
continue
457
465
}
458
- go func () {
466
+ _ = a .trackConnGoroutine (func () {
467
+ defer close (closed )
459
468
_ = a .handleReconnectingPTY (ctx , logger , msg , conn )
460
- }( )
469
+ })
461
470
}
462
471
}); err != nil {
463
472
return nil , err
You can’t perform that action at this time.
0 commit comments