Skip to content

Commit

Permalink
fix: replace time.After with time.NewTicker for improved timing accur…
Browse files Browse the repository at this point in the history
…acy and to avoid memory leaks
  • Loading branch information
iw4p committed Feb 7, 2025
1 parent 764c72d commit e494491
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion adnl/rldp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,14 @@ func (r *RLDP) recoverySender() {
timedOut := make([]*activeTransfer, 0, 128)
timedOutReq := make([]*activeRequest, 0, 128)
closerCtx := r.adnl.GetCloserCtx()
ticker := time.NewTicker(1 * time.Millisecond)
defer ticker.Stop()

for {
select {
case <-closerCtx.Done():
return
case <-time.After(1 * time.Millisecond):
case <-ticker.C:
packets = packets[:0]
transfersToProcess = transfersToProcess[:0]
timedOut = timedOut[:0]
Expand Down

0 comments on commit e494491

Please sign in to comment.