Skip to content

Commit ae36c63

Browse files
committed
Fix context return early
1 parent cc2bcde commit ae36c63

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

agent/agent.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,17 @@ func (s *server) run(ctx context.Context) {
260260
s.options.Logger.Warn(context.Background(), "failed to dial", slog.Error(err))
261261
continue
262262
}
263+
defer func() {
264+
_ = peerListener.Close()
265+
}()
263266
s.options.Logger.Debug(context.Background(), "connected")
264267
break
265268
}
269+
select {
270+
case <-ctx.Done():
271+
return
272+
default:
273+
}
266274

267275
for {
268276
conn, err := peerListener.Accept()

0 commit comments

Comments
 (0)