@@ -437,36 +437,25 @@ 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
- })
448
- _ = a .trackConnGoroutine (func () {
449
- defer close (closed )
450
- // This cannot use a JSON decoder, since that can
451
- // buffer additional data that is required for the PTY.
452
- rawLen := make ([]byte , 2 )
453
- _ , err = conn .Read (rawLen )
454
- if err != nil {
455
- return
456
- }
457
- length := binary .LittleEndian .Uint16 (rawLen )
458
- data := make ([]byte , length )
459
- _ , err = conn .Read (data )
460
- if err != nil {
461
- return
462
- }
463
- var msg codersdk.ReconnectingPTYInit
464
- err = json .Unmarshal (data , & msg )
465
- if err != nil {
466
- return
467
- }
468
- _ = a .handleReconnectingPTY (ctx , logger , msg , conn )
469
- })
440
+ // This cannot use a JSON decoder, since that can
441
+ // buffer additional data that is required for the PTY.
442
+ rawLen := make ([]byte , 2 )
443
+ _ , err = conn .Read (rawLen )
444
+ if err != nil {
445
+ continue
446
+ }
447
+ length := binary .LittleEndian .Uint16 (rawLen )
448
+ data := make ([]byte , length )
449
+ _ , err = conn .Read (data )
450
+ if err != nil {
451
+ continue
452
+ }
453
+ var msg codersdk.ReconnectingPTYInit
454
+ err = json .Unmarshal (data , & msg )
455
+ if err != nil {
456
+ continue
457
+ }
458
+ _ = a .handleReconnectingPTY (ctx , logger , msg , conn )
470
459
}
471
460
}); err != nil {
472
461
return nil , err
0 commit comments