MINOR: resolvers: Use milliseconds for cached items in resolver responses

The last time when an item was seen in a resolver responses is now stored in
milliseconds instead of seconds. This avoid some corner-cases at the
edges. This also simplifies time comparisons.

(cherry picked from commit 55c1c4053f70bf53adfcd5067fa959e20f2b44fe)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/dns.c b/src/dns.c
index a628c5c..c9ffcf7 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -629,7 +629,7 @@
 		struct dns_answer_item *ar_item = item->ar_item;
 
 		/* clean up obsolete Additional record */
-		if (ar_item && (ar_item->last_seen + resolvers->hold.obsolete / 1000) < now.tv_sec) {
+		if (ar_item && tick_is_lt(tick_add(ar_item->last_seen, resolvers->hold.obsolete), now_ms)) {
 			/* Cleaning up the AR item will trigger an extra DNS  resolution, except if the SRV
 			 * item is also obsolete.
 			 */
@@ -638,7 +638,7 @@
 		}
 
 		/* Remove obsolete items */
-		if ((item->last_seen + resolvers->hold.obsolete / 1000) < now.tv_sec) {
+		if (tick_is_lt(tick_add(item->last_seen, resolvers->hold.obsolete), now_ms)) {
 			if (item->type != DNS_RTYPE_SRV)
 				goto rm_obselete_item;
 
@@ -953,6 +953,7 @@
 
 		/* initialization */
 		dns_answer_record->ar_item = NULL;
+		dns_answer_record->last_seen = TICK_ETERNITY;
 
 		offset = 0;
 		len = dns_read_name(resp, bufend, reader, tmpname, DNS_MAX_NAME_SIZE, &offset, 0);
@@ -1148,12 +1149,12 @@
 		}
 
 		if (found == 1) {
-			tmp_record->last_seen = now.tv_sec;
+			tmp_record->last_seen = now_ms;
 			pool_free(dns_answer_item_pool, dns_answer_record);
 			dns_answer_record = NULL;
 		}
 		else {
-			dns_answer_record->last_seen = now.tv_sec;
+			dns_answer_record->last_seen = now_ms;
 			dns_answer_record->ar_item = NULL;
 			LIST_ADDQ(&dns_p->answer_list, &dns_answer_record->list);
 			dns_answer_record = NULL;
@@ -1203,6 +1204,7 @@
 		dns_answer_record = pool_alloc(dns_answer_item_pool);
 		if (dns_answer_record == NULL)
 			goto invalid_resp;
+		dns_answer_record->last_seen = TICK_ETERNITY;
 
 		offset = 0;
 		len = dns_read_name(resp, bufend, reader, tmpname, DNS_MAX_NAME_SIZE, &offset, 0);
@@ -1329,12 +1331,12 @@
 		}
 
 		if (found == 1) {
-			tmp_record->ar_item->last_seen = now.tv_sec;
+			tmp_record->ar_item->last_seen = now_ms;
 			pool_free(dns_answer_item_pool, dns_answer_record);
 			dns_answer_record = NULL;
 		}
 		else {
-			dns_answer_record->last_seen = now.tv_sec;
+			dns_answer_record->last_seen = now_ms;
 			dns_answer_record->ar_item = NULL;
 
 			// looking for the SRV record in the response list linked to this additional record