MINOR: stats: report the number of active peers in "show info"

Peers are the last type of activity which can maintain a job present, so
it's important to report that such an entity is still active to explain
why the job count may be higher than zero. Here by "ActivePeers" we report
peers sessions, which include both established connections and outgoing
connection attempts.
diff --git a/include/types/global.h b/include/types/global.h
index 4b9d019..18cc63e 100644
--- a/include/types/global.h
+++ b/include/types/global.h
@@ -224,6 +224,7 @@
 extern int  actconn;            /* # of active sessions */
 extern int  listeners;
 extern int  jobs;               /* # of active jobs (listeners, sessions, open devices) */
+extern int  active_peers;       /* # of active peers (connection attempts and successes) */
 extern THREAD_LOCAL struct buffer trash;
 extern int nb_oldpids;          /* contains the number of old pids found */
 extern const int zero;
diff --git a/include/types/stats.h b/include/types/stats.h
index 8df8489..e59a240 100644
--- a/include/types/stats.h
+++ b/include/types/stats.h
@@ -291,6 +291,7 @@
 	INF_STOPPING,
 	INF_JOBS,
 	INF_LISTENERS,
+	INF_ACTIVE_PEERS,
 
 	/* must always be the last one */
 	INF_TOTAL_FIELDS
diff --git a/src/haproxy.c b/src/haproxy.c
index 81db3e0..129ff1d 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -175,6 +175,7 @@
 int stopping;	/* non zero means stopping in progress */
 int killed;	/* non zero means a hard-stop is triggered */
 int jobs = 0;   /* number of active jobs (conns, listeners, active tasks, ...) */
+int active_peers = 0; /* number of active peers (connection attempts and connected) */
 
 /* Here we store informations about the pids of the processes we may pause
  * or kill. We will send them a signal every 10 ms until we can bind to all
diff --git a/src/peers.c b/src/peers.c
index a99d8e1..1d6dac1 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -506,6 +506,7 @@
 
 	/* peer session identified */
 	if (peer) {
+		HA_ATOMIC_SUB(&active_peers, 1);
 		HA_SPIN_LOCK(PEER_LOCK, &peer->lock);
 		if (peer->appctx == appctx) {
 			/* Re-init current table pointers to force announcement on re-connect */
@@ -718,6 +719,7 @@
 				curpeer->appctx = appctx;
 				appctx->ctx.peers.ptr = curpeer;
 				appctx->st0 = PEER_SESS_ST_SENDSUCCESS;
+				HA_ATOMIC_ADD(&active_peers, 1);
 				/* fall through */
 			}
 			case PEER_SESS_ST_SENDSUCCESS: {
@@ -1979,6 +1981,7 @@
 
 	peer->appctx = appctx;
 	task_wakeup(s->task, TASK_WOKEN_INIT);
+	HA_ATOMIC_ADD(&active_peers, 1);
 	return appctx;
 
 	/* Error unrolling */
diff --git a/src/stats.c b/src/stats.c
index cbb9870..231c172 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -133,6 +133,7 @@
 	[INF_STOPPING]                       = "Stopping",
 	[INF_JOBS]                           = "Jobs",
 	[INF_LISTENERS]                      = "Listeners",
+	[INF_ACTIVE_PEERS]                   = "ActivePeers",
 };
 
 const char *stat_field_names[ST_F_TOTAL_FIELDS] = {
@@ -3298,6 +3299,7 @@
 	info[INF_STOPPING]                       = mkf_u32(0, stopping);
 	info[INF_JOBS]                           = mkf_u32(0, jobs);
 	info[INF_LISTENERS]                      = mkf_u32(0, listeners);
+	info[INF_ACTIVE_PEERS]                   = mkf_u32(0, active_peers);
 
 	return 1;
 }