summaryrefslogtreecommitdiff
path: root/ares_timeout.c
diff options
context:
space:
mode:
authorYu Jiung <jiung.yu@samsung.com>2016-11-09 02:15:33 (GMT)
committerYu Jiung <jiung.yu@samsung.com>2016-11-09 02:15:43 (GMT)
commitb6627e2c19506bd30328969ea8aab73fa0945f36 (patch)
tree24b768763efadd60f318873601e58dd98fe9714c /ares_timeout.c
parentb8e6c26b7b9608dffc84645f17fe4cf534af18dd (diff)
downloadc-ares-b6627e2c19506bd30328969ea8aab73fa0945f36.zip
c-ares-b6627e2c19506bd30328969ea8aab73fa0945f36.tar.gz
c-ares-b6627e2c19506bd30328969ea8aab73fa0945f36.tar.bz2
Imported Upstream version 1.10.0refs/changes/17/96417/1
Change-Id: Ic7f3b0ad7dca62abe4cfa642a5eb5e190eb7a8c9
Diffstat (limited to 'ares_timeout.c')
-rw-r--r--ares_timeout.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/ares_timeout.c b/ares_timeout.c
index 2da4f5f..0b5a435 100644
--- a/ares_timeout.c
+++ b/ares_timeout.c
@@ -16,12 +16,10 @@
#include "ares_setup.h"
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
#endif
-#include <time.h>
-
#include "ares.h"
#include "ares_private.h"
@@ -62,19 +60,22 @@ struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
min_offset = offset;
}
- if(min_offset != -1) {
- nextstop.tv_sec = min_offset/1000;
- nextstop.tv_usec = (min_offset%1000)*1000;
- }
-
/* If we found a minimum timeout and it's sooner than the one specified in
* maxtv (if any), return it. Otherwise go with maxtv.
*/
- if (min_offset != -1 && (!maxtv || ares__timedout(maxtv, &nextstop)))
+ if (min_offset != -1)
{
- *tvbuf = nextstop;
- return tvbuf;
+ int ioffset = (min_offset > (long)INT_MAX) ? INT_MAX : (int)min_offset;
+
+ nextstop.tv_sec = ioffset/1000;
+ nextstop.tv_usec = (ioffset%1000)*1000;
+
+ if (!maxtv || ares__timedout(maxtv, &nextstop))
+ {
+ *tvbuf = nextstop;
+ return tvbuf;
+ }
}
- else
- return maxtv;
+
+ return maxtv;
}