BUG/MINOR: stats: properly handle server stats dumping resumption

In stats_dump_proxy_to_buffer() function, special care was taken when
dealing with servers dump.
Indeed, stats_dump_proxy_to_buffer() can be interrupted and resumed if
buffer space is not big enough to complete dump.
Thus, a reference is taken on the server being dumped in the hope that
the server will still be valid when the function resumes.
(to prevent the server from being freed in the meantime)

While this is now true thanks to:
-  "BUG/MINOR: server/del: fix legacy srv->next pointer consistency"

We still have an issue: when resuming, saved server reference is not
dropped.
This prevents the server from being freed when we no longer use it.
Moreover, as the saved server might now be deleted
(SRV_F_DELETED flag set), the current deleted server may still be dumped
in the stats and while this is not a bug, this could be misleading for
the user.

Let's add a px_st variable to detect if the stats_dump_proxy_to_buffer()
is being resumed at the STAT_PX_ST_SV stage: perform some housekeeping
to skip deleted servers and properly drop the reference on the saved
server.

This commit depends on:
 - "MINOR: server: add SRV_F_DELETED flag"
 - "BUG/MINOR: server/del: fix legacy srv->next pointer consistency"

This should be backported up to 2.6
diff --git a/src/stats.c b/src/stats.c
index 1f80509..0fe7e20 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -3142,6 +3142,7 @@
 	struct server *sv, *svs;	/* server and server-state, server-state=server or server->track */
 	struct listener *l;
 	int current_field;
+	int px_st = ctx->px_st;
 
 	chunk_reset(&trash_chunk);
 more:
@@ -3257,11 +3258,28 @@
 		__fallthrough;
 
 	case STAT_PX_ST_SV:
+		/* check for dump resumption */
+		if (px_st == STAT_PX_ST_SV) {
+			struct server *cur = ctx->obj2;
+
+			/* re-entrant dump */
+			BUG_ON(!cur);
+			if (cur->flags & SRV_F_DELETED) {
+				/* the server could have been marked as deleted
+				 * between two dumping attempts, skip it.
+				 */
+				cur = cur->next;
+			}
+			srv_drop(ctx->obj2); /* drop old srv taken on last dumping attempt */
+			ctx->obj2 = cur; /* could be NULL */
+			/* back to normal */
+		}
+
 		/* obj2 points to servers list as initialized above.
 		 *
 		 * A server may be removed during the stats dumping.
 		 * Temporarily increment its refcount to prevent its
-		 * anticipated cleaning. Call free_server to release it.
+		 * anticipated cleaning. Call srv_drop() to release it.
 		 */
 		for (; ctx->obj2 != NULL;
 		       ctx->obj2 = srv_drop(sv)) {