Commit e134a402 authored by Gisle Vanem's avatar Gisle Vanem
Browse files

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

Winsock.
parent 690888cf
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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)
+1 −1
Original line number Diff line number Diff line
@@ -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;
      }
+1 −1
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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;
Loading