MINOR: server: propagate server state change to lb through single function
Use a dedicated helper function to propagate server state change to
lb algorithms, since it is performed at multiple places within
srv_update_status() function.
diff --git a/src/server.c b/src/server.c
index 457a429..036c5a1 100644
--- a/src/server.c
+++ b/src/server.c
@@ -5273,6 +5273,23 @@
return 0;
}
+/* This function propagates srv state change to lb algorithms */
+static void srv_lb_propagate(struct server *s)
+{
+ struct proxy *px = s->proxy;
+
+ if (px->lbprm.update_server_eweight)
+ px->lbprm.update_server_eweight(s);
+ else if (srv_willbe_usable(s)) {
+ if (px->lbprm.set_server_status_up)
+ px->lbprm.set_server_status_up(s);
+ }
+ else {
+ if (px->lbprm.set_server_status_down)
+ px->lbprm.set_server_status_down(s);
+ }
+}
+
/*
* This function applies server's status changes.
*
@@ -5369,16 +5386,7 @@
server_recalc_eweight(s, 0);
/* now propagate the status change to any LB algorithms */
- if (px->lbprm.update_server_eweight)
- px->lbprm.update_server_eweight(s);
- else if (srv_willbe_usable(s)) {
- if (px->lbprm.set_server_status_up)
- px->lbprm.set_server_status_up(s);
- }
- else {
- if (px->lbprm.set_server_status_down)
- px->lbprm.set_server_status_down(s);
- }
+ srv_lb_propagate(s);
/* If the server is set with "on-marked-up shutdown-backup-sessions",
* and it's not a backup server and its effective weight is > 0,
@@ -5415,16 +5423,7 @@
}
else if (s->cur_eweight != s->next_eweight) {
/* now propagate the status change to any LB algorithms */
- if (px->lbprm.update_server_eweight)
- px->lbprm.update_server_eweight(s);
- else if (srv_willbe_usable(s)) {
- if (px->lbprm.set_server_status_up)
- px->lbprm.set_server_status_up(s);
- }
- else {
- if (px->lbprm.set_server_status_down)
- px->lbprm.set_server_status_down(s);
- }
+ srv_lb_propagate(s);
}
s->next_admin = next_admin;
@@ -5584,16 +5583,7 @@
server_recalc_eweight(s, 0);
/* now propagate the status change to any LB algorithms */
- if (px->lbprm.update_server_eweight)
- px->lbprm.update_server_eweight(s);
- else if (srv_willbe_usable(s)) {
- if (px->lbprm.set_server_status_up)
- px->lbprm.set_server_status_up(s);
- }
- else {
- if (px->lbprm.set_server_status_down)
- px->lbprm.set_server_status_down(s);
- }
+ srv_lb_propagate(s);
/* If the server is set with "on-marked-up shutdown-backup-sessions",
* and it's not a backup server and its effective weight is > 0,
@@ -5730,16 +5720,7 @@
}
/* now propagate the status change to any LB algorithms */
- if (px->lbprm.update_server_eweight)
- px->lbprm.update_server_eweight(s);
- else if (srv_willbe_usable(s)) {
- if (px->lbprm.set_server_status_up)
- px->lbprm.set_server_status_up(s);
- }
- else {
- if (px->lbprm.set_server_status_down)
- px->lbprm.set_server_status_down(s);
- }
+ srv_lb_propagate(s);
}
else if ((s->next_admin & SRV_ADMF_DRAIN)) {
/* remaining in drain mode after removing one of its flags */