MAJOR: server: use states instead of flags to store the server state

Servers used to have 3 flags to store a state, now they have 4 states
instead. This avoids lots of confusion for the 4 remaining undefined
states.

The encoding from the previous to the new states can be represented
this way :

  SRV_STF_RUNNING
   |  SRV_STF_GOINGDOWN
   |   |  SRV_STF_WARMINGUP
   |   |   |
   0   x   x     SRV_ST_STOPPED
   1   0   0     SRV_ST_RUNNING
   1   0   1     SRV_ST_STARTING
   1   1   x     SRV_ST_STOPPING

Note that the case where all bits were set used to exist and was randomly
dealt with. For example, the task was not stopped, the throttle value was
still updated and reported in the stats and in the http_server_state header.
It was the same if the server was stopped by the agent or for maintenance.

It's worth noting that the internal function names are still quite confusing.
diff --git a/include/proto/backend.h b/include/proto/backend.h
index 601a61a..31c191e 100644
--- a/include/proto/backend.h
+++ b/include/proto/backend.h
@@ -63,11 +63,15 @@
 		return 0;
 	if (srv->admin & SRV_ADMF_MAINT)
 		return 0;
-	if (state & SRV_STF_GOINGDOWN)
+	switch (state) {
+	case SRV_ST_STARTING:
+	case SRV_ST_RUNNING:
+		return 1;
+	case SRV_ST_STOPPING:
+	case SRV_ST_STOPPED:
 		return 0;
-	if (!(state & SRV_STF_RUNNING))
-		return 0;
-	return 1;
+	}
+	return 0;
 }
 
 /* This function returns non-zero if the designated server was usable for LB
@@ -81,11 +85,15 @@
 		return 0;
 	if (srv->prev_admin & SRV_ADMF_MAINT)
 		return 0;
-	if (state & SRV_STF_GOINGDOWN)
-		return 0;
-	if (!(state & SRV_STF_RUNNING))
+	switch (state) {
+	case SRV_ST_STARTING:
+	case SRV_ST_RUNNING:
+		return 1;
+	case SRV_ST_STOPPING:
+	case SRV_ST_STOPPED:
 		return 0;
-	return 1;
+	}
+	return 0;
 }
 
 /* This function commits the current server state and weight onto the previous
diff --git a/include/types/server.h b/include/types/server.h
index ba0a1a5..377ea06 100644
--- a/include/types/server.h
+++ b/include/types/server.h
@@ -43,11 +43,12 @@
 #include <types/checks.h>
 
 
-/* server states, still used as cumulative flags */
+/* server states. Only SRV_ST_DOWN indicates a down server. */
 enum srv_state {
-	SRV_STF_RUNNING    = 0x1,        /* the server is UP */
-	SRV_STF_GOINGDOWN  = 0x2,        /* the server is going down (eg: 404) */
-	SRV_STF_WARMINGUP  = 0x4,        /* the server is warming up after a failure */
+	SRV_ST_STOPPED = 0,              /* the server is down. Please keep set to zero. */
+	SRV_ST_STARTING,                 /* the server is warming up (up but throttled) */
+	SRV_ST_RUNNING,                  /* the server is fully up */
+	SRV_ST_STOPPING,                 /* the server is up but soft-stopping (eg: 404) */
 };
 
 /* Maintenance mode : each server may be in maintenance by itself or may inherit
@@ -113,7 +114,7 @@
 
 struct server {
 	enum obj_type obj_type;                 /* object type == OBJ_TYPE_SERVER */
-	enum srv_state state, prev_state;       /* server state among SRV_STF_* */
+	enum srv_state state, prev_state;       /* server state among SRV_ST_* */
 	enum srv_admin admin, prev_admin;       /* server maintenance status : SRV_ADMF_* */
 	unsigned char flags;                    /* server flags (SRV_F_*) */
 	struct server *next;