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/include/haproxy/backend.h b/include/haproxy/backend.h
index f6b25e7..8a763bf 100644
--- a/include/haproxy/backend.h
+++ b/include/haproxy/backend.h
@@ -52,7 +52,7 @@
/* Returns number of usable servers in backend */
static inline int be_usable_srv(struct proxy *be)
{
- if (be->state == PR_STSTOPPED)
+ if (be->disabled)
return 0;
else if (be->srv_act)
return be->srv_act;
diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h
index aa8038d..a17537a 100644
--- a/include/haproxy/proxy-t.h
+++ b/include/haproxy/proxy-t.h
@@ -42,13 +42,6 @@
#include <haproxy/thread-t.h>
#include <haproxy/uri_auth-t.h>
-/* values for proxy->state */
-enum pr_state {
- PR_STNEW = 0, /* proxy has not been initialized yet */
- PR_STREADY, /* proxy has been initialized and is ready */
- PR_STSTOPPED, /* proxy is stopped (end of a restart) */
-} __attribute__((packed));
-
/* values for proxy->mode */
enum pr_mode {
PR_MODE_TCP = 0,
@@ -252,7 +245,7 @@
struct proxy {
enum obj_type obj_type; /* object type == OBJ_TYPE_PROXY */
- enum pr_state state; /* proxy state, one of PR_* */
+ char disabled; /* non-zero if disabled or shutdown */
enum pr_mode mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
char cap; /* supported capabilities (PR_CAP_*) */
unsigned int maxconn; /* max # of active streams on the frontend */