]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
asyn-ares: remove typecast, fix expire
authorDaniel Stenberg <daniel@haxx.se>
Thu, 3 Oct 2024 21:53:10 +0000 (23:53 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 4 Oct 2024 12:08:09 +0000 (14:08 +0200)
- 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

lib/asyn-ares.c

index f6ad32ef36cd171d2ccb0df32b300c4b41ddad5f..ae436f236e0519a96ce2e55825bf270ed53bbb75 100644 (file)
@@ -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;
 }