BUG/MEDIUM: servers: Add a per-thread counter of idle connections.

Add a per-thread counter of idling connections, and use it to determine
how many connections we should kill after the timeout, instead of using
the global counter, or we're likely to just kill most of the connections.

This should be backported to 1.9.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index 1dc0512..45b8a8a 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -694,6 +694,7 @@
 	if (conn->idle_time > 0) {
 		struct server *srv = __objt_server(conn->target);
 		HA_ATOMIC_SUB(&srv->curr_idle_conns, 1);
+		srv->curr_idle_thr[tid]--;
 	}
 
 	conn_force_unsubscribe(conn);
diff --git a/include/proto/server.h b/include/proto/server.h
index 51d1015..9467f69 100644
--- a/include/proto/server.h
+++ b/include/proto/server.h
@@ -253,6 +253,7 @@
 		}
 		LIST_DEL(&conn->list);
 		LIST_ADDQ(&srv->idle_orphan_conns[tid], &conn->list);
+		srv->curr_idle_thr[tid]++;
 
 		conn->idle_time = now_ms;
 		if (!(task_in_wq(srv->idle_task[tid])) &&
diff --git a/include/types/server.h b/include/types/server.h
index e4371af..eae7d45 100644
--- a/include/types/server.h
+++ b/include/types/server.h
@@ -225,6 +225,7 @@
 	unsigned int pool_purge_delay;          /* Delay before starting to purge the idle conns pool */
 	unsigned int max_idle_conns;            /* Max number of connection allowed in the orphan connections list */
 	unsigned int curr_idle_conns;           /* Current number of orphan idling connections */
+	unsigned int *curr_idle_thr;            /* Current number of orphan idling connections per thread */
 	int max_reuse;                          /* Max number of requests on a same connection */
 	struct task **idle_task;                /* task responsible for cleaning idle orphan connections */
 	struct task *warmup;                    /* the task dedicated to the warmup when slowstart is set */