BUG/MINOR: resolvers: Only renew TTL for SRV records with an additional record

If no additional record is associated to a SRV record, its TTL must not be
renewed. Otherwise the entry never expires. Thus once announced a first
time, the entry remains blocked on the same IP/port except if a new announce
replaces the old one.

Now, the TTL is updated if a SRV record is received while a matching
existing one is found with an additional record or when an new additional
record is assigned to an existing SRV record.

This patch should be backported as far as 2.2.

(cherry picked from commit a331a1e8eb2ad4750711a477ca3e22d940495faf)
[cf: Changes applied in src/dns.c]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/dns.c b/src/dns.c
index 3fcf434..a054b7b 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -1097,7 +1097,8 @@
 		}
 
 		if (found == 1) {
-			tmp_record->last_seen = now.tv_sec;
+			if (tmp_record->type != DNS_RTYPE_SRV || tmp_record->ar_item != NULL)
+				tmp_record->last_seen = now.tv_sec;
 			pool_free(dns_answer_item_pool, dns_answer_record);
 			dns_answer_record = NULL;
 		}
@@ -1287,6 +1288,7 @@
 				    !dns_hostname_cmp(tmp_record->target, dns_answer_record->name, tmp_record->data_len)) {
 					/* Always use the received additional record to refresh info */
 					tmp_record->ar_item = dns_answer_record;
+					tmp_record->last_seen = dns_answer_record->last_seen;
 					dns_answer_record = NULL;
 					break;
 				}