curl-library
Multi interface infinite loop
Date: Wed, 21 Apr 2004 17:35:41 -0400
Ok got a question, I'm using the multi interface. And here is the scenario.
Say a connection "fails" (times out). The below snippet's comments
illustrate my problem
/* This finishes with cont != 0 so while is entered */
while(CURLM_CALL_MULTI_PERFORM == curl_multi_perform(multihandle, &cont))
;
while(cont) {
struct timeval timeout;
int rc;
fd_set fdread, fdwrite, fdexcep;
int maxfd;
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
curl_multi_fdset(multihandle, &fdread, &fdwrite, &fdexcep, &maxfd);
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
/* rc = 0 (timeout) */
switch(rc) {
case -1:
case 0:
/* jumps back to the top of the while */
break;
default:
while(CURLM_CALL_MULTI_PERFORM ==
curl_multi_perform(multihandle, &cont))
;
}
}
Since cont was set to !0 that one time, the loop is infinite. I copied this
code pretty much from the examples, so I'm wondering what is wrong. If a
timeout or select error occurs, what should I do? Is there something special
I must do f I want to use a select() timeout? Basically, it seems curl is
not recognizing that select() timed out, and is instead continuing to try
and connect.
Ideas?
Dominick Meglio
Received on 2004-04-21