diff --git a/include/proto/backend.h b/include/proto/backend.h index 4d37c7175..69386b838 100644 --- a/include/proto/backend.h +++ b/include/proto/backend.h @@ -42,6 +42,22 @@ int be_downtime(struct proxy *px); void init_server_map(struct proxy *p); void fwrr_init_server_groups(struct proxy *p); void fwlc_init_server_tree(struct proxy *p); +void recount_servers(struct proxy *px); +void update_backend_weight(struct proxy *px); + +/* This function returns non-zero if a server with the given weight and state + * is usable for LB, otherwise zero. + */ +static inline int srv_is_usable(int state, int weight) +{ + if (!weight) + return 0; + if (state & SRV_GOINGDOWN) + return 0; + if (!(state & SRV_RUNNING)) + return 0; + return 1; +} /* * This function tries to find a running server with free connection slots for @@ -90,26 +106,6 @@ static inline struct server *get_server_rr_with_conns(struct proxy *px, struct s } -/* - * This function tries to find a running server for the proxy following - * the round-robin method. - * If any server is found, it will be returned and px->lbprm.map.rr_idx will be updated - * to point to the next server. If no valid server is found, NULL is returned. - */ -static inline struct server *get_server_rr(struct proxy *px) -{ - if (px->lbprm.tot_weight == 0) - return NULL; - - if (px->lbprm.map.state & PR_MAP_RECALC) - recalc_server_map(px); - - if (px->lbprm.map.rr_idx < 0 || px->lbprm.map.rr_idx >= px->lbprm.tot_weight) - px->lbprm.map.rr_idx = 0; - return px->lbprm.map.srv[px->lbprm.map.rr_idx++]; -} - - /* * This function tries to find a running server for the proxy following * the source hash method. Depending on the number of active/backup servers, diff --git a/src/backend.c b/src/backend.c index 05ce1ef21..648d79747 100644 --- a/src/backend.c +++ b/src/backend.c @@ -44,20 +44,6 @@ static inline void fwrr_dequeue_srv(struct server *s); static void fwrr_get_srv(struct server *s); static void fwrr_queue_srv(struct server *s); -/* This function returns non-zero if a server with the given weight and state - * is usable for LB, otherwise zero. - */ -static inline int srv_is_usable(int state, int weight) -{ - if (!weight) - return 0; - if (state & SRV_GOINGDOWN) - return 0; - if (!(state & SRV_RUNNING)) - return 0; - return 1; -} - /* * This function recounts the number of usable active and backup servers for * proxy

. These numbers are returned into the p->srv_act and p->srv_bck. @@ -65,7 +51,7 @@ static inline int srv_is_usable(int state, int weight) * it does not update tot_weight nor tot_used. Use update_backend_weight() for * this. */ -static void recount_servers(struct proxy *px) +void recount_servers(struct proxy *px) { struct server *srv; @@ -93,7 +79,7 @@ static void recount_servers(struct proxy *px) * after servers weights have been updated. It is designed to be used after * recount_servers() or equivalent. */ -static void update_backend_weight(struct proxy *px) +void update_backend_weight(struct proxy *px) { if (px->srv_act) { px->lbprm.tot_weight = px->lbprm.tot_wact;