mirror of
https://github.com/moparisthebest/curl
synced 2025-01-11 05:58:01 -05:00
timeouts: move ms timeouts to timediff_t from int and long
Now that all functions in select.[ch] take timediff_t instead
of the limited int or long, we can remove type conversions
and related preprocessor checks to silence compiler warnings.
Avoiding conversions from time_t was already done in 842f73de
.
Based upon #5262
Supersedes #5214, #5220 and #5221
Follow up to #5343 and #5479
Closes #5490
This commit is contained in:
parent
e2de2d5397
commit
3186f50054
@ -286,7 +286,7 @@ int Curl_resolver_getsock(struct connectdata *conn,
|
||||
* return number of sockets it worked on
|
||||
*/
|
||||
|
||||
static int waitperform(struct connectdata *conn, int timeout_ms)
|
||||
static int waitperform(struct connectdata *conn, timediff_t timeout_ms)
|
||||
{
|
||||
struct Curl_easy *data = conn->data;
|
||||
int nfds;
|
||||
@ -437,9 +437,13 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
|
||||
while(!result) {
|
||||
struct timeval *tvp, tv, store;
|
||||
int itimeout;
|
||||
int timeout_ms;
|
||||
timediff_t timeout_ms;
|
||||
|
||||
itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
|
||||
#if TIMEDIFF_T_MAX > INT_MAX
|
||||
itimeout = (timeout > INT_MAX) ? INT_MAX : (int)timeout;
|
||||
#else
|
||||
itimeout = (int)timeout;
|
||||
#endif
|
||||
|
||||
store.tv_sec = itimeout/1000;
|
||||
store.tv_usec = (itimeout%1000)*1000;
|
||||
@ -450,7 +454,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
|
||||
second is left, otherwise just use 1000ms to make sure the progress
|
||||
callback gets called frequent enough */
|
||||
if(!tvp->tv_sec)
|
||||
timeout_ms = (int)(tvp->tv_usec/1000);
|
||||
timeout_ms = (timediff_t)(tvp->tv_usec/1000);
|
||||
else
|
||||
timeout_ms = 1000;
|
||||
|
||||
@ -470,7 +474,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
|
||||
else if(timediff > timeout)
|
||||
timeout = -1;
|
||||
else
|
||||
timeout -= (long)timediff;
|
||||
timeout -= timediff;
|
||||
now = now2; /* for next loop */
|
||||
}
|
||||
if(timeout < 0)
|
||||
|
@ -510,7 +510,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
|
||||
before = Curl_now();
|
||||
|
||||
/* wait for activity or timeout */
|
||||
pollrc = Curl_poll(fds, numfds, (int)ev->ms);
|
||||
pollrc = Curl_poll(fds, numfds, ev->ms);
|
||||
|
||||
after = Curl_now();
|
||||
|
||||
|
@ -1255,7 +1255,7 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
|
||||
timeout */
|
||||
else if((sleep_ms < 0) && extrawait)
|
||||
sleep_ms = timeout_ms;
|
||||
Curl_wait_ms((int)sleep_ms);
|
||||
Curl_wait_ms(sleep_ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
|
||||
break;
|
||||
}
|
||||
if(!timeout_ms)
|
||||
timeout_ms = TIME_T_MAX;
|
||||
timeout_ms = TIMEDIFF_T_MAX;
|
||||
if(SOCKET_READABLE(sockfd, timeout_ms) <= 0) {
|
||||
result = ~CURLE_OK;
|
||||
break;
|
||||
|
@ -1315,7 +1315,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
||||
DWORD readfile_read;
|
||||
int err;
|
||||
#else
|
||||
int interval_ms;
|
||||
timediff_t interval_ms;
|
||||
struct pollfd pfd[2];
|
||||
int poll_cnt;
|
||||
curl_off_t total_dl = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user