Skip to content

Commit

Permalink
curl_easy_perform: gradually increase the delay time
Browse files Browse the repository at this point in the history
Instead of going 50,100,150 etc millisecond delay time when nothing has
been found to do or wait for, we now start lower and double each loop as
in 4,8,16,32 etc.

This lowers the minimum wait without sacrifizing the longer wait too
much with unnecessary CPU cycles burnt.

Bug: http://curl.haxx.se/mail/lib-2013-07/0103.html
Reported-by: Andreas Malzahn
  • Loading branch information
bagder committed Jul 19, 2013
1 parent e2e9248 commit d529f38
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/easy.c
Expand Up @@ -539,9 +539,7 @@ CURLcode curl_easy_perform(CURL *easy)
if(curlx_tvdiff(after, before) <= 10) { if(curlx_tvdiff(after, before) <= 10) {
without_fds++; without_fds++;
if(without_fds > 2) { if(without_fds > 2) {
int sleep_ms = without_fds * 50; int sleep_ms = without_fds < 10 ? (1 << (without_fds-1)): 1000;
if(sleep_ms > 1000)
sleep_ms = 1000;
Curl_wait_ms(sleep_ms); Curl_wait_ms(sleep_ms);
} }
} }
Expand Down

1 comment on commit d529f38

@remoe
Copy link
Contributor

@remoe remoe commented on d529f38 Jul 30, 2013

Choose a reason for hiding this comment

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

Please sign in to comment.