]> git.99rst.org Git - openwrt-packages.git/blob
54d3b8c303e1f449a8ac790e43147a1cbb776c72
[openwrt-packages.git] /
1 commit 5550143cd6de58c6e733e389c6946e3dd26e89c0
2 Author: Willy Tarreau <w@1wt.eu>
3 Date: Tue Aug 7 10:44:58 2018 +0200
4
5 BUG/MEDIUM: queue: prevent a backup server from draining the proxy's connections
6
7 When switching back from a backup to an active server, the backup server
8 currently continues to drain the proxy's connections, which is a problem
9 because it's not expected to be able to pick them.
10
11 This patch ensures that a backup server will only pick backend connections
12 if there is no active server and it is the selected backup server or all
13 backup servers are supposed to be used.
14
15 This issue seems to have existed forever, so this fix should be backported
16 to all stable versions.
17
18 (cherry picked from commit a8694654ba021bf1e0e560a98ab5e70dc44d212e)
19 Signed-off-by: Willy Tarreau <w@1wt.eu>
20
21 diff --git a/src/queue.c b/src/queue.c
22 index 1c730c75..b0b89426 100644
23 --- a/src/queue.c
24 +++ b/src/queue.c
25 @@ -117,7 +117,10 @@ static int pendconn_process_next_strm(struct server *srv, struct proxy *px)
26 }
27
28 ps_found:
29 - if (srv_currently_usable(rsrv) && px->nbpend) {
30 + if (srv_currently_usable(rsrv) && px->nbpend &&
31 + (!(srv->flags & SRV_F_BACKUP) ||
32 + (!px->srv_act &&
33 + (srv == px->lbprm.fbck || (px->options & PR_O_USE_ALL_BK))))) {
34 struct pendconn *pp;
35
36 list_for_each_entry(pp, &px->pendconns, list) {
37 @@ -287,6 +290,15 @@ int pendconn_grab_from_px(struct server *s)
38 if (!srv_currently_usable(s))
39 return 0;
40
41 + /* if this is a backup server and there are active servers or at
42 + * least another backup server was elected, then this one must
43 + * not dequeue requests from the proxy.
44 + */
45 + if ((s->flags & SRV_F_BACKUP) &&
46 + (s->proxy->srv_act ||
47 + ((s != s->proxy->lbprm.fbck) && !(s->proxy->options & PR_O_USE_ALL_BK))))
48 + return 0;
49 +
50 HA_SPIN_LOCK(PROXY_LOCK, &s->proxy->lock);
51 maxconn = srv_dynamic_maxconn(s);
52 list_for_each_entry_safe(p, pback, &s->proxy->pendconns, list) {
git clone https://git.99rst.org/PROJECT