MEDIUM: proxy: replace proxy->state with proxy->disabled

The remaining proxy states were only used to distinguish an enabled
proxy from a disabled one. Due to the initialization order, both
PR_STNEW and PR_STREADY were equivalent after startup, and they
would only differ from PR_STSTOPPED when the proxy is disabled or
shutdown (which is effectively another way to disable it).

Now we just have a "disabled" field which allows to distinguish them.
It's becoming obvious that start_proxies() is only used to print a
greeting message now, that we'd rather get rid of. Probably that
zombify_proxy() and stop_proxy() should be merged once their
differences move to the right place.
diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c
index 665be76..cda55e6 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -245,7 +245,7 @@
 		memcpy(&curproxy->defsrv, &defproxy.defsrv, sizeof(curproxy->defsrv));
 		curproxy->defsrv.id = "default-server";
 
-		curproxy->state = defproxy.state;
+		curproxy->disabled = defproxy.disabled;
 		curproxy->options = defproxy.options;
 		curproxy->options2 = defproxy.options2;
 		curproxy->no_options = defproxy.no_options;
@@ -783,12 +783,12 @@
 	else if (!strcmp(args[0], "disabled")) {  /* disables this proxy */
 		if (alertif_too_many_args(0, file, linenum, args, &err_code))
 			goto out;
-		curproxy->state = PR_STSTOPPED;
+		curproxy->disabled = 1;
 	}
 	else if (!strcmp(args[0], "enabled")) {  /* enables this proxy (used to revert a disabled default) */
 		if (alertif_too_many_args(0, file, linenum, args, &err_code))
 			goto out;
-		curproxy->state = PR_STNEW;
+		curproxy->disabled = 0;
 	}
 	else if (!strcmp(args[0], "bind-process")) {  /* enable this proxy only on some processes */
 		int cur_arg = 1;
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 92d02ca..0bc4b82 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -414,7 +414,7 @@
 {
 	init_new_proxy(&defproxy);
 	defproxy.mode = PR_MODE_TCP;
-	defproxy.state = PR_STNEW;
+	defproxy.disabled = 0;
 	defproxy.maxconn = cfg_maxpconn;
 	defproxy.conn_retries = CONN_RETRIES;
 	defproxy.redispatch_after = 0;
@@ -2117,7 +2117,7 @@
 	if (!(from->cap & PR_CAP_FE))
 		return;
 
-	if (from->state == PR_STSTOPPED)
+	if (from->disabled)
 		return;
 
 	/* default_backend */
@@ -2234,7 +2234,7 @@
 		next_pxid++;
 
 
-		if (curproxy->state == PR_STSTOPPED) {
+		if (curproxy->disabled) {
 			/* ensure we don't keep listeners uselessly bound. We
 			 * can't disable their listeners yet (fdtab not
 			 * allocated yet) but let's skip them.
@@ -3949,7 +3949,7 @@
 	 * other proxies.
 	 */
 	for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
-		if (curproxy->state == PR_STSTOPPED || !curproxy->table)
+		if (curproxy->disabled || !curproxy->table)
 			continue;
 
 		if (!stktable_init(curproxy->table)) {
diff --git a/src/check.c b/src/check.c
index 8d3cd6f..88c78ed 100644
--- a/src/check.c
+++ b/src/check.c
@@ -859,7 +859,7 @@
 		 * is disabled.
 		 */
 		if (((check->state & (CHK_ST_ENABLED | CHK_ST_PAUSED)) != CHK_ST_ENABLED) ||
-		    proxy->state == PR_STSTOPPED)
+		    proxy->disabled)
 			goto reschedule;
 
 		/* we'll initiate a new check */
diff --git a/src/cli.c b/src/cli.c
index f34f991..b331bd3 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -2428,7 +2428,6 @@
 	proxies_list = mworker_proxy;
 	mworker_proxy->id = strdup("MASTER");
 	mworker_proxy->mode = PR_MODE_CLI;
-	mworker_proxy->state = PR_STNEW;
 	mworker_proxy->last_change = now.tv_sec;
 	mworker_proxy->cap = PR_CAP_LISTEN; /* this is a listen section */
 	mworker_proxy->maxconn = 10;                 /* default to 10 concurrent connections */
diff --git a/src/extcheck.c b/src/extcheck.c
index dd7c942..96d61c9 100644
--- a/src/extcheck.c
+++ b/src/extcheck.c
@@ -495,7 +495,7 @@
 		 * is disabled.
 		 */
 		if (((check->state & (CHK_ST_ENABLED | CHK_ST_PAUSED)) != CHK_ST_ENABLED) ||
-		    s->proxy->state == PR_STSTOPPED)
+		    s->proxy->disabled)
 			goto reschedule;
 
 		/* we'll initiate a new check */
diff --git a/src/haproxy.c b/src/haproxy.c
index aa865f0..23cfa24 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -2010,7 +2010,7 @@
 				break;
 
 		for (px = proxies_list; px; px = px->next)
-			if (px->state != PR_STSTOPPED && px->li_all)
+			if (!px->disabled && px->li_all)
 				break;
 
 		if (pr || px) {
@@ -2340,7 +2340,7 @@
 
 	/* stop disabled proxies */
 	for (px = proxies_list; px; px = px->next) {
-		if (px->state == PR_STSTOPPED)
+		if (px->disabled)
 			stop_proxy(px);
 	}
 
@@ -3511,7 +3511,7 @@
 		/* we might have to unbind some proxies from some processes */
 		px = proxies_list;
 		while (px != NULL) {
-			if (px->bind_proc && px->state != PR_STSTOPPED) {
+			if (px->bind_proc && !px->disabled) {
 				if (!(px->bind_proc & (1UL << proc))) {
 					if (global.tune.options & GTUNE_SOCKET_TRANSFER)
 						zombify_proxy(px);
@@ -3525,7 +3525,7 @@
 		/* we might have to unbind some log forward proxies from some processes */
 		px = cfg_log_forward;
 		while (px != NULL) {
-			if (px->bind_proc && px->state != PR_STSTOPPED) {
+			if (px->bind_proc && !px->disabled) {
 				if (!(px->bind_proc & (1UL << proc))) {
 					if (global.tune.options & GTUNE_SOCKET_TRANSFER)
 						zombify_proxy(px);
diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c
index b6b1feb..2856cf2 100644
--- a/src/mux_fcgi.c
+++ b/src/mux_fcgi.c
@@ -3001,7 +3001,7 @@
 	}
 	fcgi_send(fconn);
 
-	if (unlikely(fconn->proxy->state == PR_STSTOPPED)) {
+	if (unlikely(fconn->proxy->disabled)) {
 		/* frontend is stopping, reload likely in progress, let's try
 		 * to announce a graceful shutdown if not yet done. We don't
 		 * care if it fails, it will be tried again later.
diff --git a/src/mux_h1.c b/src/mux_h1.c
index a7fed2a..23cc72f 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -888,7 +888,7 @@
 	}
 
 	/* If KAL, check if the frontend is stopping. If yes, switch in CLO mode */
-	if (h1s->flags & H1S_F_WANT_KAL && fe->state == PR_STSTOPPED) {
+	if (h1s->flags & H1S_F_WANT_KAL && fe->disabled) {
 		h1s->flags = (h1s->flags & ~H1S_F_WANT_MSK) | H1S_F_WANT_CLO;
 		TRACE_STATE("stopping, set close mode", H1_EV_RX_DATA|H1_EV_RX_HDRS|H1_EV_TX_DATA|H1_EV_TX_HDRS, h1s->h1c->conn, h1s);
 	}
@@ -952,7 +952,7 @@
 	}
 
 	/* If KAL, check if the backend is stopping. If yes, switch in CLO mode */
-	if (h1s->flags & H1S_F_WANT_KAL && be->state == PR_STSTOPPED) {
+	if (h1s->flags & H1S_F_WANT_KAL && be->disabled) {
 		h1s->flags = (h1s->flags & ~H1S_F_WANT_MSK) | H1S_F_WANT_CLO;
 		TRACE_STATE("stopping, set close mode", H1_EV_RX_DATA|H1_EV_RX_HDRS|H1_EV_TX_DATA|H1_EV_TX_HDRS, h1s->h1c->conn, h1s);
 	}
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 9c87218..1b73d2b 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -3609,7 +3609,7 @@
 	}
 	h2_send(h2c);
 
-	if (unlikely(h2c->proxy->state == PR_STSTOPPED)) {
+	if (unlikely(h2c->proxy->disabled)) {
 		/* frontend is stopping, reload likely in progress, let's try
 		 * to announce a graceful shutdown if not yet done. We don't
 		 * care if it fails, it will be tried again later.
diff --git a/src/mworker.c b/src/mworker.c
index d6365e1..2ef7e7d 100644
--- a/src/mworker.c
+++ b/src/mworker.c
@@ -437,7 +437,7 @@
 		}
 		/* if the proxy shouldn't be in the master, we stop it */
 		if (!listen_in_master)
-			curproxy->state = PR_STSTOPPED;
+			curproxy->disabled = 1;
 	}
 }
 
diff --git a/src/proxy.c b/src/proxy.c
index bae8c14..7bcfa95 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -1052,10 +1052,8 @@
 	struct proxy *curproxy;
 
 	for (curproxy = proxies_list; curproxy != NULL; curproxy = curproxy->next) {
-		if (curproxy->state != PR_STNEW)
-			continue; /* already initialized */
-
-		curproxy->state = PR_STREADY;
+		if (curproxy->disabled)
+			continue;
 		send_log(curproxy, LOG_NOTICE, "Proxy %s started.\n", curproxy->id);
 	}
 }
@@ -1078,7 +1076,7 @@
 	 */
 
 	/* first, let's check if we need to stop the proxy */
-	if (unlikely(stopping && p->state != PR_STSTOPPED)) {
+	if (unlikely(stopping && !p->disabled)) {
 		int t;
 		t = tick_remain(now_ms, p->stop_time);
 		if (t == 0) {
@@ -1102,7 +1100,7 @@
 	 * be in neither list. Any entry being dumped will have ref_cnt > 0.
 	 * However we protect tables that are being synced to peers.
 	 */
-	if (unlikely(stopping && p->state == PR_STSTOPPED && p->table && p->table->current)) {
+	if (unlikely(stopping && p->disabled && p->table && p->table->current)) {
 		if (!p->table->syncing) {
 			stktable_trash_oldest(p->table, p->table->current);
 			pool_gc(NULL);
@@ -1230,7 +1228,7 @@
 	p = proxies_list;
 	tv_update_date(0,1); /* else, the old time before select will be used */
 	while (p) {
-		if (p->state != PR_STSTOPPED) {
+		if (!p->disabled) {
 			ha_warning("Stopping %s %s in %d ms.\n", proxy_cap_str(p->cap), p->id, p->grace);
 			send_log(p, LOG_WARNING, "Stopping %s %s in %d ms.\n", proxy_cap_str(p->cap), p->id, p->grace);
 			p->stop_time = tick_add(now_ms, p->grace);
@@ -1257,7 +1255,7 @@
 	p = cfg_log_forward;
 	while (p) {
 		/* Zombie proxy, let's close the file descriptors */
-		if (p->state == PR_STSTOPPED &&
+		if (p->disabled &&
 		    !LIST_ISEMPTY(&p->conf.listeners) &&
 		    LIST_ELEM(p->conf.listeners.n,
 		    struct listener *, by_fe)->state > LI_ASSIGNED) {
@@ -1269,7 +1267,7 @@
 			}
 		}
 
-		if (p->state != PR_STSTOPPED) {
+		if (!p->disabled) {
 			stop_proxy(p);
 		}
 		p = p->next;
@@ -1288,7 +1286,7 @@
 {
 	struct listener *l;
 
-	if (!(p->cap & PR_CAP_FE) || p->state == PR_STSTOPPED || !p->li_ready)
+	if (!(p->cap & PR_CAP_FE) || p->disabled || !p->li_ready)
 		return 1;
 
 	ha_warning("Pausing %s %s.\n", proxy_cap_str(p->cap), p->id);
@@ -1318,7 +1316,7 @@
 		if (l->state >= LI_ASSIGNED)
 			delete_listener(l);
 	}
-	p->state = PR_STSTOPPED;
+	p->disabled = 1;
 }
 
 /*
@@ -1352,7 +1350,7 @@
 		}
 	}
 	if (!nostop)
-		p->state = PR_STSTOPPED;
+		p->disabled = 1;
 
 	HA_SPIN_UNLOCK(PROXY_LOCK, &p->lock);
 }
@@ -1367,7 +1365,7 @@
 	struct listener *l;
 	int fail;
 
-	if (p->state == PR_STSTOPPED || !p->li_paused)
+	if (p->disabled || !p->li_paused)
 		return 1;
 
 	ha_warning("Enabling %s %s.\n", proxy_cap_str(p->cap), p->id);
@@ -1685,7 +1683,7 @@
 	struct switching_rule *swrule1, *swrule2;
 
 	for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
-		if (curproxy->state == PR_STSTOPPED)
+		if (curproxy->disabled)
 			continue;
 
 		if (!(curproxy->cap & PR_CAP_FE))
@@ -1729,7 +1727,7 @@
 	 * loop above because cross-references are not yet fully resolved.
 	 */
 	for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
-		if (curproxy->state == PR_STSTOPPED)
+		if (curproxy->disabled)
 			continue;
 
 		/* If <fullconn> is not set, let's set it to 10% of the sum of
@@ -2187,7 +2185,7 @@
 	if (!px)
 		return 1;
 
-	if (px->state == PR_STSTOPPED)
+	if (px->disabled)
 		return cli_msg(appctx, LOG_NOTICE, "Frontend was already shut down.\n");
 
 	ha_warning("Proxy %s stopped (cumulated conns: FE: %lld, BE: %lld).\n",
@@ -2215,7 +2213,7 @@
 	if (!px)
 		return 1;
 
-	if (px->state == PR_STSTOPPED)
+	if (px->disabled)
 		return cli_msg(appctx, LOG_NOTICE, "Frontend was previously shut down, cannot disable.\n");
 
 	if (!px->li_ready)
@@ -2247,7 +2245,7 @@
 	if (!px)
 		return 1;
 
-	if (px->state == PR_STSTOPPED)
+	if (px->disabled)
 		return cli_err(appctx, "Frontend was previously shut down, cannot enable.\n");
 
 	if (px->li_ready == px->li_all)
diff --git a/src/server.c b/src/server.c
index 4de4543..45b0f41 100644
--- a/src/server.c
+++ b/src/server.c
@@ -4246,7 +4246,7 @@
 		return NULL;
 	}
 
-	if (px->state == PR_STSTOPPED) {
+	if (px->disabled) {
 		cli_err(appctx, "Proxy is disabled.\n");
 		return NULL;
 	}
diff --git a/src/stats.c b/src/stats.c
index 132011d..033ed16 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -1629,7 +1629,7 @@
 	stats[ST_F_EREQ]     = mkf_u64(FN_COUNTER, px->fe_counters.failed_req);
 	stats[ST_F_DCON]     = mkf_u64(FN_COUNTER, px->fe_counters.denied_conn);
 	stats[ST_F_DSES]     = mkf_u64(FN_COUNTER, px->fe_counters.denied_sess);
-	stats[ST_F_STATUS]   = mkf_str(FO_STATUS, px->state == PR_STREADY ? "OPEN" : "STOP");
+	stats[ST_F_STATUS]   = mkf_str(FO_STATUS, px->disabled ? "STOP" : "OPEN");
 	stats[ST_F_PID]      = mkf_u32(FO_KEY, relative_pid);
 	stats[ST_F_IID]      = mkf_u32(FO_KEY|FS_SERVICE, px->uuid);
 	stats[ST_F_SID]      = mkf_u32(FO_KEY|FS_SERVICE, 0);
@@ -3044,9 +3044,7 @@
 
 		px = appctx->ctx.stats.obj1;
 		/* skip the disabled proxies, global frontend and non-networked ones */
-		if (px->state != PR_STSTOPPED && px->uuid > 0
-		    && (px->cap & (PR_CAP_FE | PR_CAP_BE))) {
-
+		if (!px->disabled && px->uuid > 0 && (px->cap & (PR_CAP_FE | PR_CAP_BE))) {
 			if (stats_dump_proxy_to_buffer(si, htx, px, uri) == 0)
 				return 0;
 		}
@@ -3458,7 +3456,7 @@
 						total_servers++;
 						break;
 					case ST_ADM_ACTION_SHUTDOWN:
-						if (px->state != PR_STSTOPPED) {
+						if (!px->disabled) {
 							srv_shutdown_streams(sv, SF_ERR_KILLED);
 							altered_servers++;
 							total_servers++;
diff --git a/src/stick_table.c b/src/stick_table.c
index 69bd7ad..ff93e39 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -640,7 +640,7 @@
 			t->exp_task->process = process_table_expire;
 			t->exp_task->context = (void *)t;
 		}
-		if (t->peers.p && t->peers.p->peers_fe && t->peers.p->peers_fe->state != PR_STSTOPPED) {
+		if (t->peers.p && t->peers.p->peers_fe && !t->peers.p->peers_fe->disabled) {
 			peers_register_table(t->peers.p, t);
 		}
 
diff --git a/src/stream.c b/src/stream.c
index b298d7b..bcb9acf 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -702,7 +702,7 @@
 	pool_free(pool_head_stream, s);
 
 	/* We may want to free the maximum amount of pools if the proxy is stopping */
-	if (fe && unlikely(fe->state == PR_STSTOPPED)) {
+	if (fe && unlikely(fe->disabled)) {
 		pool_flush(pool_head_buffer);
 		pool_flush(pool_head_http_txn);
 		pool_flush(pool_head_requri);