Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Fast Weighted Least Connection load balancing algorithm. |
| 3 | * |
| 4 | * Copyright 2000-2009 Willy Tarreau <w@1wt.eu> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <common/compat.h> |
| 14 | #include <common/config.h> |
| 15 | #include <common/debug.h> |
Willy Tarreau | 45cb4fb | 2009-10-26 21:10:04 +0100 | [diff] [blame] | 16 | #include <eb32tree.h> |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 17 | |
| 18 | #include <types/global.h> |
| 19 | #include <types/server.h> |
| 20 | |
| 21 | #include <proto/backend.h> |
| 22 | #include <proto/queue.h> |
| 23 | |
| 24 | |
| 25 | /* Remove a server from a tree. It must have previously been dequeued. This |
| 26 | * function is meant to be called when a server is going down or has its |
| 27 | * weight disabled. |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 28 | * |
| 29 | * The server's lock and the lbprm's lock must be held. |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 30 | */ |
| 31 | static inline void fwlc_remove_from_tree(struct server *s) |
| 32 | { |
| 33 | s->lb_tree = NULL; |
| 34 | } |
| 35 | |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 36 | /* simply removes a server from a tree. |
| 37 | * |
| 38 | * The server's lock and the lbprm's lock must be held. |
| 39 | */ |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 40 | static inline void fwlc_dequeue_srv(struct server *s) |
| 41 | { |
| 42 | eb32_delete(&s->lb_node); |
| 43 | } |
| 44 | |
| 45 | /* Queue a server in its associated tree, assuming the weight is >0. |
Willy Tarreau | 1eb6c55 | 2018-12-14 08:33:28 +0100 | [diff] [blame] | 46 | * Servers are sorted by (#conns+1)/weight. To ensure maximum accuracy, |
| 47 | * we use (#conns+1)*SRV_EWGHT_MAX/eweight as the sorting key. The reason |
| 48 | * for using #conns+1 is to sort by weights in case the server is picked |
| 49 | * and not before it is picked. This provides a better load accuracy for |
| 50 | * low connection counts when weights differ and makes sure the round-robin |
Willy Tarreau | 345ddf4 | 2019-09-06 17:04:04 +0200 | [diff] [blame] | 51 | * applies between servers of highest weight first. However servers with no |
| 52 | * connection are always picked first so that under low loads, it's not |
| 53 | * always the single server with the highest weight that gets picked. |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 54 | * |
| 55 | * The server's lock and the lbprm's lock must be held. |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 56 | */ |
| 57 | static inline void fwlc_queue_srv(struct server *s) |
| 58 | { |
Willy Tarreau | 345ddf4 | 2019-09-06 17:04:04 +0200 | [diff] [blame] | 59 | s->lb_node.key = s->served ? (s->served + 1) * SRV_EWGHT_MAX / s->next_eweight : 0; |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 60 | eb32_insert(s->lb_tree, &s->lb_node); |
| 61 | } |
| 62 | |
| 63 | /* Re-position the server in the FWLC tree after it has been assigned one |
| 64 | * connection or after it has released one. Note that it is possible that |
| 65 | * the server has been moved out of the tree due to failed health-checks. |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 66 | * |
| 67 | * The server's lock must be held. The lbprm's lock will be used. |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 68 | */ |
| 69 | static void fwlc_srv_reposition(struct server *s) |
| 70 | { |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 71 | HA_SPIN_LOCK(LBPRM_LOCK, &s->proxy->lbprm.lock); |
Christopher Faulet | 3f0b1de | 2019-06-19 10:50:38 +0200 | [diff] [blame] | 72 | if (s->lb_tree) { |
| 73 | fwlc_dequeue_srv(s); |
| 74 | fwlc_queue_srv(s); |
| 75 | } |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 76 | HA_SPIN_UNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock); |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | /* This function updates the server trees according to server <srv>'s new |
| 80 | * state. It should be called when server <srv>'s status changes to down. |
| 81 | * It is not important whether the server was already down or not. It is not |
| 82 | * important either that the new state is completely down (the caller may not |
| 83 | * know all the variables of a server's state). |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 84 | * |
| 85 | * The server's lock must be held. The lbprm's lock will be used. |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 86 | */ |
| 87 | static void fwlc_set_server_status_down(struct server *srv) |
| 88 | { |
| 89 | struct proxy *p = srv->proxy; |
| 90 | |
Willy Tarreau | c5150da | 2014-05-13 19:27:31 +0200 | [diff] [blame] | 91 | if (!srv_lb_status_changed(srv)) |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 92 | return; |
| 93 | |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 94 | if (srv_willbe_usable(srv)) |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 95 | goto out_update_state; |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 96 | HA_SPIN_LOCK(LBPRM_LOCK, &p->lbprm.lock); |
| 97 | |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 98 | |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 99 | if (!srv_currently_usable(srv)) |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 100 | /* server was already down */ |
| 101 | goto out_update_backend; |
| 102 | |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 103 | if (srv->flags & SRV_F_BACKUP) { |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 104 | p->lbprm.tot_wbck -= srv->cur_eweight; |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 105 | p->srv_bck--; |
| 106 | |
| 107 | if (srv == p->lbprm.fbck) { |
| 108 | /* we lost the first backup server in a single-backup |
| 109 | * configuration, we must search another one. |
| 110 | */ |
| 111 | struct server *srv2 = p->lbprm.fbck; |
| 112 | do { |
| 113 | srv2 = srv2->next; |
| 114 | } while (srv2 && |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 115 | !((srv2->flags & SRV_F_BACKUP) && |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 116 | srv_willbe_usable(srv2))); |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 117 | p->lbprm.fbck = srv2; |
| 118 | } |
| 119 | } else { |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 120 | p->lbprm.tot_wact -= srv->cur_eweight; |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 121 | p->srv_act--; |
| 122 | } |
| 123 | |
| 124 | fwlc_dequeue_srv(srv); |
| 125 | fwlc_remove_from_tree(srv); |
| 126 | |
| 127 | out_update_backend: |
| 128 | /* check/update tot_used, tot_weight */ |
| 129 | update_backend_weight(p); |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 130 | HA_SPIN_UNLOCK(LBPRM_LOCK, &p->lbprm.lock); |
| 131 | |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 132 | out_update_state: |
Willy Tarreau | c5150da | 2014-05-13 19:27:31 +0200 | [diff] [blame] | 133 | srv_lb_commit_status(srv); |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /* This function updates the server trees according to server <srv>'s new |
| 137 | * state. It should be called when server <srv>'s status changes to up. |
| 138 | * It is not important whether the server was already down or not. It is not |
| 139 | * important either that the new state is completely UP (the caller may not |
| 140 | * know all the variables of a server's state). This function will not change |
| 141 | * the weight of a server which was already up. |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 142 | * |
| 143 | * The server's lock must be held. The lbprm's lock will be used. |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 144 | */ |
| 145 | static void fwlc_set_server_status_up(struct server *srv) |
| 146 | { |
| 147 | struct proxy *p = srv->proxy; |
| 148 | |
Willy Tarreau | c5150da | 2014-05-13 19:27:31 +0200 | [diff] [blame] | 149 | if (!srv_lb_status_changed(srv)) |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 150 | return; |
| 151 | |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 152 | if (!srv_willbe_usable(srv)) |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 153 | goto out_update_state; |
| 154 | |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 155 | HA_SPIN_LOCK(LBPRM_LOCK, &p->lbprm.lock); |
| 156 | |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 157 | if (srv_currently_usable(srv)) |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 158 | /* server was already up */ |
| 159 | goto out_update_backend; |
| 160 | |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 161 | if (srv->flags & SRV_F_BACKUP) { |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 162 | srv->lb_tree = &p->lbprm.fwlc.bck; |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 163 | p->lbprm.tot_wbck += srv->next_eweight; |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 164 | p->srv_bck++; |
| 165 | |
| 166 | if (!(p->options & PR_O_USE_ALL_BK)) { |
| 167 | if (!p->lbprm.fbck) { |
| 168 | /* there was no backup server anymore */ |
| 169 | p->lbprm.fbck = srv; |
| 170 | } else { |
| 171 | /* we may have restored a backup server prior to fbck, |
| 172 | * in which case it should replace it. |
| 173 | */ |
| 174 | struct server *srv2 = srv; |
| 175 | do { |
| 176 | srv2 = srv2->next; |
| 177 | } while (srv2 && (srv2 != p->lbprm.fbck)); |
| 178 | if (srv2) |
| 179 | p->lbprm.fbck = srv; |
| 180 | } |
| 181 | } |
| 182 | } else { |
| 183 | srv->lb_tree = &p->lbprm.fwlc.act; |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 184 | p->lbprm.tot_wact += srv->next_eweight; |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 185 | p->srv_act++; |
| 186 | } |
| 187 | |
| 188 | /* note that eweight cannot be 0 here */ |
| 189 | fwlc_queue_srv(srv); |
| 190 | |
| 191 | out_update_backend: |
| 192 | /* check/update tot_used, tot_weight */ |
| 193 | update_backend_weight(p); |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 194 | HA_SPIN_UNLOCK(LBPRM_LOCK, &p->lbprm.lock); |
| 195 | |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 196 | out_update_state: |
Willy Tarreau | c5150da | 2014-05-13 19:27:31 +0200 | [diff] [blame] | 197 | srv_lb_commit_status(srv); |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | /* This function must be called after an update to server <srv>'s effective |
| 201 | * weight. It may be called after a state change too. |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 202 | * |
| 203 | * The server's lock must be held. The lbprm's lock will be used. |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 204 | */ |
| 205 | static void fwlc_update_server_weight(struct server *srv) |
| 206 | { |
| 207 | int old_state, new_state; |
| 208 | struct proxy *p = srv->proxy; |
| 209 | |
Willy Tarreau | c5150da | 2014-05-13 19:27:31 +0200 | [diff] [blame] | 210 | if (!srv_lb_status_changed(srv)) |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 211 | return; |
| 212 | |
| 213 | /* If changing the server's weight changes its state, we simply apply |
| 214 | * the procedures we already have for status change. If the state |
| 215 | * remains down, the server is not in any tree, so it's as easy as |
| 216 | * updating its values. If the state remains up with different weights, |
| 217 | * there are some computations to perform to find a new place and |
| 218 | * possibly a new tree for this server. |
| 219 | */ |
| 220 | |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 221 | old_state = srv_currently_usable(srv); |
| 222 | new_state = srv_willbe_usable(srv); |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 223 | |
| 224 | if (!old_state && !new_state) { |
Willy Tarreau | c5150da | 2014-05-13 19:27:31 +0200 | [diff] [blame] | 225 | srv_lb_commit_status(srv); |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 226 | return; |
| 227 | } |
| 228 | else if (!old_state && new_state) { |
| 229 | fwlc_set_server_status_up(srv); |
| 230 | return; |
| 231 | } |
| 232 | else if (old_state && !new_state) { |
| 233 | fwlc_set_server_status_down(srv); |
| 234 | return; |
| 235 | } |
| 236 | |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 237 | HA_SPIN_LOCK(LBPRM_LOCK, &p->lbprm.lock); |
| 238 | |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 239 | if (srv->lb_tree) |
| 240 | fwlc_dequeue_srv(srv); |
| 241 | |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 242 | if (srv->flags & SRV_F_BACKUP) { |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 243 | p->lbprm.tot_wbck += srv->next_eweight - srv->cur_eweight; |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 244 | srv->lb_tree = &p->lbprm.fwlc.bck; |
| 245 | } else { |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 246 | p->lbprm.tot_wact += srv->next_eweight - srv->cur_eweight; |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 247 | srv->lb_tree = &p->lbprm.fwlc.act; |
| 248 | } |
| 249 | |
| 250 | fwlc_queue_srv(srv); |
| 251 | |
| 252 | update_backend_weight(p); |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 253 | HA_SPIN_UNLOCK(LBPRM_LOCK, &p->lbprm.lock); |
| 254 | |
Willy Tarreau | c5150da | 2014-05-13 19:27:31 +0200 | [diff] [blame] | 255 | srv_lb_commit_status(srv); |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | /* This function is responsible for building the trees in case of fast |
| 259 | * weighted least-conns. It also sets p->lbprm.wdiv to the eweight to |
| 260 | * uweight ratio. Both active and backup groups are initialized. |
| 261 | */ |
| 262 | void fwlc_init_server_tree(struct proxy *p) |
| 263 | { |
| 264 | struct server *srv; |
| 265 | struct eb_root init_head = EB_ROOT; |
| 266 | |
| 267 | p->lbprm.set_server_status_up = fwlc_set_server_status_up; |
| 268 | p->lbprm.set_server_status_down = fwlc_set_server_status_down; |
| 269 | p->lbprm.update_server_eweight = fwlc_update_server_weight; |
| 270 | p->lbprm.server_take_conn = fwlc_srv_reposition; |
| 271 | p->lbprm.server_drop_conn = fwlc_srv_reposition; |
| 272 | |
| 273 | p->lbprm.wdiv = BE_WEIGHT_SCALE; |
| 274 | for (srv = p->srv; srv; srv = srv->next) { |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 275 | srv->next_eweight = (srv->uweight * p->lbprm.wdiv + p->lbprm.wmult - 1) / p->lbprm.wmult; |
Willy Tarreau | c5150da | 2014-05-13 19:27:31 +0200 | [diff] [blame] | 276 | srv_lb_commit_status(srv); |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | recount_servers(p); |
| 280 | update_backend_weight(p); |
| 281 | |
| 282 | p->lbprm.fwlc.act = init_head; |
| 283 | p->lbprm.fwlc.bck = init_head; |
| 284 | |
| 285 | /* queue active and backup servers in two distinct groups */ |
| 286 | for (srv = p->srv; srv; srv = srv->next) { |
Emeric Brun | 52a91d3 | 2017-08-31 14:41:55 +0200 | [diff] [blame] | 287 | if (!srv_currently_usable(srv)) |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 288 | continue; |
Willy Tarreau | c93cd16 | 2014-05-13 15:54:22 +0200 | [diff] [blame] | 289 | srv->lb_tree = (srv->flags & SRV_F_BACKUP) ? &p->lbprm.fwlc.bck : &p->lbprm.fwlc.act; |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 290 | fwlc_queue_srv(srv); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | /* Return next server from the FWLC tree in backend <p>. If the tree is empty, |
| 295 | * return NULL. Saturated servers are skipped. |
Willy Tarreau | 1b87748 | 2018-08-21 19:44:53 +0200 | [diff] [blame] | 296 | * |
| 297 | * The server's lock must be held. The lbprm's lock will be used. |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 298 | */ |
| 299 | struct server *fwlc_get_next_server(struct proxy *p, struct server *srvtoavoid) |
| 300 | { |
| 301 | struct server *srv, *avoided; |
| 302 | struct eb32_node *node; |
| 303 | |
| 304 | srv = avoided = NULL; |
| 305 | |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 306 | HA_SPIN_LOCK(LBPRM_LOCK, &p->lbprm.lock); |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 307 | if (p->srv_act) |
| 308 | node = eb32_first(&p->lbprm.fwlc.act); |
Christopher Faulet | 5b51755 | 2017-06-09 14:17:53 +0200 | [diff] [blame] | 309 | else if (p->lbprm.fbck) { |
| 310 | srv = p->lbprm.fbck; |
| 311 | goto out; |
| 312 | } |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 313 | else if (p->srv_bck) |
| 314 | node = eb32_first(&p->lbprm.fwlc.bck); |
Christopher Faulet | 5b51755 | 2017-06-09 14:17:53 +0200 | [diff] [blame] | 315 | else { |
| 316 | srv = NULL; |
| 317 | goto out; |
| 318 | } |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 319 | |
| 320 | while (node) { |
| 321 | /* OK, we have a server. However, it may be saturated, in which |
| 322 | * case we don't want to reconsider it for now, so we'll simply |
| 323 | * skip it. Same if it's the server we try to avoid, in which |
| 324 | * case we simply remember it for later use if needed. |
| 325 | */ |
| 326 | struct server *s; |
| 327 | |
| 328 | s = eb32_entry(node, struct server, lb_node); |
| 329 | if (!s->maxconn || (!s->nbpend && s->served < srv_dynamic_maxconn(s))) { |
| 330 | if (s != srvtoavoid) { |
| 331 | srv = s; |
| 332 | break; |
| 333 | } |
| 334 | avoided = s; |
| 335 | } |
| 336 | node = eb32_next(node); |
| 337 | } |
| 338 | |
| 339 | if (!srv) |
| 340 | srv = avoided; |
Christopher Faulet | 5b51755 | 2017-06-09 14:17:53 +0200 | [diff] [blame] | 341 | out: |
Christopher Faulet | 2a944ee | 2017-11-07 10:42:54 +0100 | [diff] [blame] | 342 | HA_SPIN_UNLOCK(LBPRM_LOCK, &p->lbprm.lock); |
Willy Tarreau | f89c187 | 2009-10-01 11:19:37 +0200 | [diff] [blame] | 343 | return srv; |
| 344 | } |
| 345 | |
| 346 | |
| 347 | /* |
| 348 | * Local variables: |
| 349 | * c-indent-level: 8 |
| 350 | * c-basic-offset: 8 |
| 351 | * End: |
| 352 | */ |