From: Daniel Stenberg Date: Thu, 3 Oct 2024 21:53:10 +0000 (+0200) Subject: asyn-ares: remove typecast, fix expire X-Git-Tag: curl-8_11_0~238 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6f454bab750751d0cb9d55fcbeff18d6435ccc3e;p=thirdparty%2Fcurl.git asyn-ares: remove typecast, fix expire - Use the appropriate variable type for the curlx_tvtoms() return code: timediff_t and remove the typecast. - Simplify the function and avoid the odd expire adjustment that probably is a rest from ancient days when the expire function did not handle zero millisecond timeouts. Closes #15145 --- diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index f6ad32ef36..ae436f236e 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -290,23 +290,14 @@ static void destroy_async_data(struct Curl_async *async) int Curl_resolver_getsock(struct Curl_easy *data, curl_socket_t *socks) { - struct timeval maxtime; + struct timeval maxtime = { CURL_TIMEOUT_RESOLVE, 0 }; struct timeval timebuf; - struct timeval *timeout; - long milli; int max = ares_getsock((ares_channel)data->state.async.resolver, (ares_socket_t *)socks, MAX_SOCKSPEREASYHANDLE); - - maxtime.tv_sec = CURL_TIMEOUT_RESOLVE; - maxtime.tv_usec = 0; - - timeout = ares_timeout((ares_channel)data->state.async.resolver, &maxtime, - &timebuf); - milli = (long)curlx_tvtoms(timeout); - if(milli == 0) - milli += 10; + struct timeval *timeout = + ares_timeout((ares_channel)data->state.async.resolver, &maxtime, &timebuf); + timediff_t milli = curlx_tvtoms(timeout); Curl_expire(data, milli, EXPIRE_ASYNC_NAME); - return max; }