Added select_test() function to allow selecting on no sockets on

Winsock.
This commit is contained in:
Gisle Vanem 2006-09-10 19:01:04 +00:00
parent 690888cfc1
commit e134a40208
9 changed files with 26 additions and 7 deletions

View File

@ -9,6 +9,21 @@ extern void curl_memlimit(int);
/* test is provided in the test code file */
int test(char *url);
int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc,
struct timeval *tv)
{
#ifdef WIN32
/* Winsock doesn't like no socket set in 'rd', 'wr' or 'exc'. This is
* case when 'num_fds <= 0. So sleep.
*/
if (num_fds <= 0) {
Sleep(1000*tv->tv_sec + tv->tv_usec/1000);
return 0;
}
#endif
return select(num_fds, rd, wr, exc, tv);
}
char *arg2=NULL;
int main(int argc, char **argv)

View File

@ -67,7 +67,7 @@ int test(char *URL)
return 89;
}
if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
fprintf(stderr, "bad select??\n");
return 95;
}

View File

@ -77,7 +77,7 @@ int test(char *URL)
ret = 3;
break;
}
rc = select(max_fd+1, &rd, &wr, &exc, &interval);
rc = select_test(max_fd+1, &rd, &wr, &exc, &interval);
fprintf(stderr, "select returned %d\n", rc);
/* we only allow a certain number of loops to avoid hanging here

View File

@ -28,7 +28,7 @@ int test(char *URL)
timeout.tv_sec = 1;
timeout.tv_usec = 0;
curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
rc = select_test(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
switch(rc) {
case -1:
break;

View File

@ -241,7 +241,7 @@ int test(char *URL)
break;
}
if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
fprintf(stderr, "bad select??\n");
i =95;
break;

View File

@ -114,7 +114,7 @@ int test(char *URL)
break;
}
if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
fprintf(stderr, "bad select??\n");
res = 195;
break;

View File

@ -106,7 +106,7 @@ int test(char *URL)
break;
}
if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
fprintf(stderr, "bad select??\n");
res = 195;
break;

View File

@ -83,7 +83,7 @@ int test(char *URL)
break;
}
if (select(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
if (select_test(max_fd+1, &rd, &wr, &exc, &interval) == -1) {
fprintf(stderr, "bad select??\n");
res = 195;
break;

View File

@ -32,5 +32,9 @@
#endif
extern char *arg2; /* set by first.c to the argv[2] or NULL */
int select_test (int num_fds, fd_set *rd, fd_set *wr, fd_set *exc,
struct timeval *tv);
int test(char *URL); /* the actual test function provided by each individual
libXXX.c file */