-
Notifications
You must be signed in to change notification settings - Fork 178
test: ping has extra delay at the end #4862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an issue where the ping function had an extra delay at the end of its execution. The change modifies the loop structure to avoid waiting for a final tick after all ping attempts have been sent.
Key changes:
- Restructured the ping sending loop to break before the final sleep/tick wait
- Changed from a traditional for loop to a manual counter decrement approach
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| defer log.HandlePanic() | ||
| defer wg.Done() | ||
| for i := uint16(0); i < p.attempts; i++ { | ||
|
|
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If p.attempts is 0, the loop will run indefinitely since i will underflow when decremented. Add a check to handle the case where p.attempts is 0, or ensure p.attempts is always greater than 0.
| if p.attempts == 0 { | |
| // No packets to send; avoid underflow in the decrementing loop. | |
| return | |
| } |
| defer wg.Done() | ||
| for i := uint16(0); i < p.attempts; i++ { | ||
|
|
||
| i := p.attempts |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable i should retain the uint16 type annotation for clarity and to match the original type, e.g., i := uint16(p.attempts) or ensure type consistency with the original loop counter.
Fixes: #4861