Commit 97d2e4bd authored by Peter Wang's avatar Peter Wang Committed by Daniel Stenberg
Browse files

Curl_poll + Curl_wait_ms: fix timeout return value

Curl_poll and Curl_wait_ms require the fix applied to Curl_socket_check
in commits b61e8b81 and c771968a:

When poll or select are interrupted and coincides with the timeout
elapsing, the functions return -1 indicating an error instead of 0 for
the timeout.
parent 33a95659
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -108,8 +108,10 @@ int Curl_wait_ms(int timeout_ms)
    if(error && error_not_EINTR)
      break;
    pending_ms = timeout_ms - elapsed_ms;
    if(pending_ms <= 0)
    if(pending_ms <= 0) {
      r = 0;  /* Simulate a "call timed out" case */
      break;
    }
  } while(r == -1);
#endif /* USE_WINSOCK */
  if(r)
@@ -432,9 +434,11 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
      break;
    if(timeout_ms > 0) {
      pending_ms = timeout_ms - elapsed_ms;
      if(pending_ms <= 0)
      if(pending_ms <= 0) {
        r = 0;  /* Simulate a "call timed out" case */
        break;
      }
    }
  } while(r == -1);

  if(r < 0)
@@ -517,9 +521,11 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
      break;
    if(timeout_ms > 0) {
      pending_ms = timeout_ms - elapsed_ms;
      if(pending_ms <= 0)
      if(pending_ms <= 0) {
        r = 0;  /* Simulate a "call timed out" case */
        break;
      }
    }
  } while(r == -1);

  if(r < 0)