cURL / Mailing Lists / curl-library / Single Mail

curl-library

timeout return value in Curl_poll, Curl_wait_ms

From: Peter Wang <novalazy_at_gmail.com>
Date: Tue, 29 Jul 2014 14:33:07 +1000

Hi,

I think Curl_poll and perhaps Curl_wait_ms require the fix applied to
Curl_socket_check in commits b61e8b8 and c771968.

That is, 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.

Peter

diff --git a/lib/select.c b/lib/select.c
index da3082d..bb9b8b0 100644
--- a/lib/select.c
+++ b/lib/select.c
@@ -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,8 +434,10 @@ 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);
 
@@ -517,8 +521,10 @@ 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);
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-07-29