BUG/MINOR: resolvers: answser item list was randomly purged or errors

In case of SRV records, The answer item list was purged by the
error callback of the first requester which considers the error
could not be safely ignored. It makes this item list unavailable
for subsequent requesters even if they consider the error
could be ignored.

On A resolution or do_resolve action error, the answer items were
never trashed.

This patch re-work the error callbacks and the code to check the return code
If a callback return 1, we consider the error was ignored and
the answer item list must be kept. At the opposite, If all error callbacks
of all requesters of the same resolution returns 0 the list will be purged

This patch should be backported as far as 2.0.

(cherry picked from commit 12ca658dbe5bc3a3f47de06b2c19d5f0ee08941e)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/server.c b/src/server.c
index be4e6e1..7f4e34f 100644
--- a/src/server.c
+++ b/src/server.c
@@ -3441,8 +3441,8 @@
 /*
  * SRV record error management callback
  * returns:
- *  0 on error
- *  1 when no error or safe ignore
+ *  0 if we can trash answser items.
+ *  1 when safely ignored and we must kept answer items
  *
  * Grabs the server's lock.
  */
@@ -3457,7 +3457,7 @@
 	/* SRV records */
 	srvrq = objt_resolv_srvrq(requester->owner);
 	if (!srvrq)
-		return 1;
+		return 0;
 
 	resolvers = srvrq->resolvers;
 	res = requester->resolution;
@@ -3507,16 +3507,14 @@
 		HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
 	}
 
-	resolv_purge_resolution_answer_records(res);
-
-	return 1;
+	return 0;
 }
 
 /*
  * Server Name Resolution error management callback
  * returns:
- *  0 on error
- *  1 when no error or safe ignore
+ *  0 if we can trash answser items.
+ *  1 when safely ignored and we must kept answer items
  *
  * Grabs the server's lock.
  */
@@ -3526,11 +3524,16 @@
 
 	s = objt_server(requester->owner);
 	if (!s)
-		return 1;
+		return 0;
+
 	HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
-	if (!snr_update_srv_status(s, 1))
+	if (!snr_update_srv_status(s, 1)) {
 		memset(&s->addr, 0, sizeof(s->addr));
+		HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
+		return 0;
+	}
 	HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
+
 	return 1;
 }