aboutsummaryrefslogtreecommitdiff
path: root/docs/examples
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2010-04-24 12:14:21 +0200
committerKamil Dudka <kdudka@redhat.com>2010-04-24 12:14:21 +0200
commitd487ade72c5f31703ce097e8460e0225fad80348 (patch)
treefd22f7cbc0e11a42bafbc3d2099df6bb2f405ed4 /docs/examples
parent71be565cf48f17b21eebbcde1ddba27c6e06d4c5 (diff)
test536: do not fail with threaded DNS resolver
Also tweaked comments in certain examples using curl_multi_fdset().
Diffstat (limited to 'docs/examples')
-rw-r--r--docs/examples/fopen.c8
-rw-r--r--docs/examples/multi-app.c8
-rw-r--r--docs/examples/multi-debugcallback.c8
-rw-r--r--docs/examples/multi-double.c8
-rw-r--r--docs/examples/multi-post.c8
-rw-r--r--docs/examples/multi-single.c8
6 files changed, 30 insertions, 18 deletions
diff --git a/docs/examples/fopen.c b/docs/examples/fopen.c
index e3814e6ab..35e24b11f 100644
--- a/docs/examples/fopen.c
+++ b/docs/examples/fopen.c
@@ -131,7 +131,6 @@ fill_buffer(URL_FILE *file,int want,int waittime)
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
- int maxfd;
struct timeval timeout;
int rc;
@@ -144,6 +143,7 @@ fill_buffer(URL_FILE *file,int want,int waittime)
/* attempt to fill buffer */
do
{
+ int maxfd = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
@@ -156,8 +156,10 @@ fill_buffer(URL_FILE *file,int want,int waittime)
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* In a real-world program you OF COURSE check the return code of the
- function calls, *and* you make sure that maxfd is bigger than -1
- so that the call to select() below makes sense! */
+ function calls. On success, the value of maxfd is guaranteed to be
+ greater or equal than -1. We call select(maxfd + 1, ...), specially
+ in case of (maxfd == -1), we call select(0, ...), which is basically
+ equal to sleep. */
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
diff --git a/docs/examples/multi-app.c b/docs/examples/multi-app.c
index a86dd0efd..38b50cd0d 100644
--- a/docs/examples/multi-app.c
+++ b/docs/examples/multi-app.c
@@ -66,7 +66,7 @@ int main(int argc, char **argv)
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
- int maxfd;
+ int maxfd = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
@@ -80,8 +80,10 @@ int main(int argc, char **argv)
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* In a real-world program you OF COURSE check the return code of the
- function calls, *and* you make sure that maxfd is bigger than -1 so
- that the call to select() below makes sense! */
+ function calls. On success, the value of maxfd is guaranteed to be
+ greater or equal than -1. We call select(maxfd + 1, ...), specially in
+ case of (maxfd == -1), we call select(0, ...), which is basically equal
+ to sleep. */
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
diff --git a/docs/examples/multi-debugcallback.c b/docs/examples/multi-debugcallback.c
index b10b47cd1..8e964c67b 100644
--- a/docs/examples/multi-debugcallback.c
+++ b/docs/examples/multi-debugcallback.c
@@ -140,7 +140,7 @@ int main(int argc, char **argv)
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
- int maxfd;
+ int maxfd = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
@@ -154,8 +154,10 @@ int main(int argc, char **argv)
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* In a real-world program you OF COURSE check the return code of the
- function calls, *and* you make sure that maxfd is bigger than -1
- so that the call to select() below makes sense! */
+ function calls. On success, the value of maxfd is guaranteed to be
+ greater or equal than -1. We call select(maxfd + 1, ...), specially in
+ case of (maxfd == -1), we call select(0, ...), which is basically equal
+ to sleep. */
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
diff --git a/docs/examples/multi-double.c b/docs/examples/multi-double.c
index ef3bf92fc..bc5b446ea 100644
--- a/docs/examples/multi-double.c
+++ b/docs/examples/multi-double.c
@@ -57,7 +57,7 @@ int main(int argc, char **argv)
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
- int maxfd;
+ int maxfd = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
@@ -71,8 +71,10 @@ int main(int argc, char **argv)
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* In a real-world program you OF COURSE check the return code of the
- function calls, *and* you make sure that maxfd is bigger than -1 so
- that the call to select() below makes sense! */
+ function calls. On success, the value of maxfd is guaranteed to be
+ greater or equal than -1. We call select(maxfd + 1, ...), specially in
+ case of (maxfd == -1), we call select(0, ...), which is basically equal
+ to sleep. */
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
diff --git a/docs/examples/multi-post.c b/docs/examples/multi-post.c
index 229e84306..0d3f78e5e 100644
--- a/docs/examples/multi-post.c
+++ b/docs/examples/multi-post.c
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
- int maxfd;
+ int maxfd = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
@@ -91,8 +91,10 @@ int main(int argc, char *argv[])
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* In a real-world program you OF COURSE check the return code of the
- function calls, *and* you make sure that maxfd is bigger than -1
- so that the call to select() below makes sense! */
+ function calls. On success, the value of maxfd is guaranteed to be
+ greater or equal than -1. We call select(maxfd + 1, ...), specially in
+ case of (maxfd == -1), we call select(0, ...), which is basically equal
+ to sleep. */
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
diff --git a/docs/examples/multi-single.c b/docs/examples/multi-single.c
index 3e236f326..cba4f32cc 100644
--- a/docs/examples/multi-single.c
+++ b/docs/examples/multi-single.c
@@ -51,7 +51,7 @@ int main(int argc, char **argv)
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
- int maxfd;
+ int maxfd = -1;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
@@ -65,8 +65,10 @@ int main(int argc, char **argv)
curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd);
/* In a real-world program you OF COURSE check the return code of the
- function calls, *and* you make sure that maxfd is bigger than -1 so
- that the call to select() below makes sense! */
+ function calls. On success, the value of maxfd is guaranteed to be
+ greater or equal than -1. We call select(maxfd + 1, ...), specially in
+ case of (maxfd == -1), we call select(0, ...), which is basically equal
+ to sleep. */
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);