Skip to content
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

[change] Random pause for every 10 successfull sent requests #131

Merged
merged 7 commits into from
May 10, 2024

Conversation

Dhanus3133
Copy link
Member

@Dhanus3133 Dhanus3133 commented May 3, 2024

Closes #128

@@ -195,6 +197,11 @@ send_data() {
done
# retry sending same data again in next cycle
[ "$failures" -eq "$MAX_RETRIES" ] && break
# pause for a while after every 10 successful request sent
if [ $((success_count % 10)) -eq 0 ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't 0 % 10 == 0 ? Why not just use [ $success_rate -ge 10 ] which is more readable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-ge makes it run whenever the success_rate is more than or equal to 10. But as per the issue, it was meant for every 10 requests. Was I right on this one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requirement is to pause every 10 successful requests.
I don't see any success_rate variable in this diff, @pandafy where is success_rate coming from?
I only see success_count here.

@@ -118,6 +118,7 @@ handle_sigusr1() {
}

send_data() {
success=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After having reviewed the code I think you were right in setting this to zero, my calculation was incorrect.

@nemesifier nemesifier merged commit ea94503 into openwisp:master May 10, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[change] Introduce random pause in sending of accumulated data
3 participants