MAJOR/REORG: dns: DNS resolution task and requester queues

This patch is a major upgrade of the internal run-time DNS resolver in
HAProxy and it brings the following 2 main changes:

1. DNS resolution task

Up to now, DNS resolution was triggered by the health check task.
From now, DNS resolution task is autonomous. It is started by HAProxy
right after the scheduler is available and it is woken either when a
network IO occurs for one of its nameserver or when a timeout is
matched.

From now, this means we can enable DNS resolution for a server without
enabling health checking.

2. Introduction of a dns_requester structure

Up to now, DNS resolution was purposely made for resolving server
hostnames.
The idea, is to ensure that any HAProxy internal object should be able
to trigger a DNS resolution. For this purpose, 2 things has to be done:
  - clean up the DNS code from the server structure (this was already
    quite clean actually) and clean up the server's callbacks from
    manipulating too much DNS resolution
  - create an agnostic structure which allows linking a DNS resolution
    and a requester of any type (using obj_type enum)

3. Manage requesters through queues

Up to now, there was an uniq relationship between a resolution and it's
owner (aka the requester now). It's a shame, because in some cases,
multiple objects may share the same hostname and may benefit from a
resolution being performed by a third party.
This patch introduces the notion of queues, which are basically lists of
either currently running resolution or waiting ones.

The resolutions are now available as a pool, which belongs to the resolvers.
The pool has has a default size of 64 resolutions per resolvers and is
allocated at configuration parsing.
diff --git a/include/types/dns.h b/include/types/dns.h
index de9c713..7a19aa3 100644
--- a/include/types/dns.h
+++ b/include/types/dns.h
@@ -82,6 +82,9 @@
 /* DNS header size */
 #define DNS_HEADER_SIZE		sizeof(struct dns_header)
 
+/* DNS resolution pool size, per resolvers section */
+#define DNS_DEFAULT_RESOLUTION_POOL_SIZE	64
+
 /* DNS request or response header structure */
 struct dns_header {
 	uint16_t id;
@@ -157,7 +160,12 @@
 		int other;              /*   other dns response errors */
 	} hold;
 	struct task *t;			/* timeout management */
-	struct list curr_resolution;	/* current running resolutions */
+	int resolution_pool_size;	/* size of the resolution pool associated to this resolvers section */
+	struct {
+		struct list pool;	/* resolution pool dedicated to this resolvers section */
+		struct list wait;	/* resolutions managed to this resolvers section */
+		struct list curr;	/* current running resolutions */
+	} resolution;
 	struct eb_root query_ids;	/* tree to quickly lookup/retrieve query ids currently in use */
 					/* used by each nameserver, but stored in resolvers since there must */
 					/* be a unique relation between an eb_root and an eb_node (resolution) */
@@ -218,11 +226,15 @@
  */
 struct dns_resolution {
 	struct list list;		/* resolution list */
-	void *requester;		/* owner of this name resolution */
+	struct {
+		struct list wait;	/* list of standby requesters for this resolution */
+		struct list curr;	/* list of requesters currently active on this resolution */
+	} requester;
 	int (*requester_cb)(struct dns_resolution *, struct dns_nameserver *);
 					/* requester callback for valid response */
 	int (*requester_error_cb)(struct dns_resolution *, int);
 					/* requester callback, for error management */
+	int uuid;			/* unique id (used for debugging purpose) */
 	char *hostname_dn;		/* server hostname in domain name label format */
 	int hostname_dn_len;		/* server domain name label len */
 	unsigned int last_resolution;	/* time of the lastest valid resolution */
@@ -244,6 +256,19 @@
 	struct chunk response_buffer;	/* buffer used as a data store for <response> above TODO: optimize the size (might be smaller) */
 };
 
+/*
+ * structure used to describe the owner of a DNS resolution.
+ */
+struct dns_requester {
+	struct list list;		/* requester list */
+	enum obj_type *requester;	/* pointer to the requester */
+	int prefered_query_type;	/* prefered query type */
+	int (*requester_cb)(struct dns_requester *, struct dns_nameserver *);
+					/* requester callback for valid response */
+	int (*requester_error_cb)(struct dns_requester *, int);
+					/* requester callback, for error management */
+};
+
 /* last resolution status code */
 enum {
 	RSLV_STATUS_NONE	= 0,	/* no resolution occured yet */