Skip to content

Commit ff0477b

Browse files
call discover context cancel function to avoid a context leak
1 parent d978518 commit ff0477b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

p2p/stream/common/streammanager/streammanager.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ func (sm *streamManager) discover(ctx context.Context) (<-chan libp2p_peer.AddrI
504504
return nil, nil
505505
}
506506

507-
ctx2, _ := context.WithTimeout(ctx, discTimeout)
507+
ctx2, cancel := context.WithTimeout(ctx, discTimeout)
508+
defer cancel()
508509
return sm.pf.FindPeers(ctx2, string(sm.myProtoID), discBatch)
509510
}
510511

0 commit comments

Comments
 (0)