Skip to content

Commit

Permalink
examples: use do/while loop for multi examples
Browse files Browse the repository at this point in the history
It's conceivable that after the first time curl_multi_perform returns,
the outvalue still_running will be 0, but work will have been done. This
is shown by a workload of small, purely file:// based URLs. Ensure that
we always read pending messages off the multi handle by forcing the
while loop to run at least once.
  • Loading branch information
falconindy authored and bagder committed Aug 27, 2012
1 parent 54faab6 commit 4c070de
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/examples/multi-app.c
Expand Up @@ -70,7 +70,7 @@ int main(void)
/* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running);

while(still_running) {
do {
struct timeval timeout;
int rc; /* select() return code */

Expand Down Expand Up @@ -118,7 +118,7 @@ int main(void)
curl_multi_perform(multi_handle, &still_running);
break;
}
}
} while(still_running);

/* See how the transfers went */
while ((msg = curl_multi_info_read(multi_handle, &msgs_left))) {
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/multi-debugcallback.c
Expand Up @@ -144,7 +144,7 @@ int main(void)
/* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running);

while(still_running) {
do {
struct timeval timeout;
int rc; /* select() return code */

Expand Down Expand Up @@ -195,7 +195,7 @@ int main(void)
curl_multi_perform(multi_handle, &still_running);
break;
}
}
} while(still_running);

curl_multi_cleanup(multi_handle);

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/multi-double.c
Expand Up @@ -59,7 +59,7 @@ int main(void)
/* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running);

while(still_running) {
do {
struct timeval timeout;
int rc; /* select() return code */

Expand Down Expand Up @@ -108,7 +108,7 @@ int main(void)
curl_multi_perform(multi_handle, &still_running);
break;
}
}
} while(still_running);

curl_multi_cleanup(multi_handle);

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/multi-post.c
Expand Up @@ -80,7 +80,7 @@ int main(void)

curl_multi_perform(multi_handle, &still_running);

while(still_running) {
do {
struct timeval timeout;
int rc; /* select() return code */

Expand Down Expand Up @@ -131,7 +131,7 @@ int main(void)
printf("running: %d!\n", still_running);
break;
}
}
} while(still_running);

curl_multi_cleanup(multi_handle);

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/multi-single.c
Expand Up @@ -55,7 +55,7 @@ int main(void)
/* we start some action by calling perform right away */
curl_multi_perform(multi_handle, &still_running);

while(still_running) {
do {
struct timeval timeout;
int rc; /* select() return code */

Expand Down Expand Up @@ -106,7 +106,7 @@ int main(void)
curl_multi_perform(multi_handle, &still_running);
break;
}
}
} while(still_running);

curl_multi_cleanup(multi_handle);

Expand Down

0 comments on commit 4c070de

Please sign in to comment.