From d487ade72c5f31703ce097e8460e0225fad80348 Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Sat, 24 Apr 2010 12:14:21 +0200 Subject: test536: do not fail with threaded DNS resolver Also tweaked comments in certain examples using curl_multi_fdset(). --- docs/examples/fopen.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'docs/examples/fopen.c') 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); -- cgit v1.2.3