blob: 7cad813bf061f38e61c0e23facfc4a232f4c5fb0 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 * Queue management functions.
3 *
Willy Tarreauac68c5d2009-10-04 23:12:44 +02004 * Copyright 2000-2009 Willy Tarreau <w@1wt.eu>
Willy Tarreaubaaee002006-06-26 02:48:02 +02005 *
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
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020013#include <common/config.h>
Willy Tarreaue4d7e552007-05-13 20:19:55 +020014#include <common/memory.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020015#include <common/time.h>
Christopher Faulet8ba59142017-06-27 15:43:53 +020016#include <common/hathreads.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020017
Willy Tarreaubaaee002006-06-26 02:48:02 +020018#include <proto/queue.h>
19#include <proto/server.h>
Willy Tarreau87b09662015-04-03 00:22:06 +020020#include <proto/stream.h>
Willy Tarreau9e000c62011-03-10 14:03:36 +010021#include <proto/stream_interface.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020022#include <proto/task.h>
23
24
Willy Tarreaubafbe012017-11-24 17:34:44 +010025struct pool_head *pool_head_pendconn;
Willy Tarreaue4d7e552007-05-13 20:19:55 +020026
27/* perform minimal intializations, report 0 in case of error, 1 if OK. */
28int init_pendconn()
29{
Willy Tarreaubafbe012017-11-24 17:34:44 +010030 pool_head_pendconn = create_pool("pendconn", sizeof(struct pendconn), MEM_F_SHARED);
31 return pool_head_pendconn != NULL;
Willy Tarreaue4d7e552007-05-13 20:19:55 +020032}
Willy Tarreaubaaee002006-06-26 02:48:02 +020033
34/* returns the effective dynamic maxconn for a server, considering the minconn
Willy Tarreau86034312006-12-29 00:10:33 +010035 * and the proxy's usage relative to its dynamic connections limit. It is
Willy Tarreau9909fc12007-11-30 17:42:05 +010036 * expected that 0 < s->minconn <= s->maxconn when this is called. If the
37 * server is currently warming up, the slowstart is also applied to the
38 * resulting value, which can be lower than minconn in this case, but never
39 * less than 1.
Willy Tarreaubaaee002006-06-26 02:48:02 +020040 */
Willy Tarreaub17916e2006-10-15 15:17:57 +020041unsigned int srv_dynamic_maxconn(const struct server *s)
Willy Tarreaubaaee002006-06-26 02:48:02 +020042{
Willy Tarreau9909fc12007-11-30 17:42:05 +010043 unsigned int max;
44
Willy Tarreau86034312006-12-29 00:10:33 +010045 if (s->proxy->beconn >= s->proxy->fullconn)
46 /* no fullconn or proxy is full */
Willy Tarreau9909fc12007-11-30 17:42:05 +010047 max = s->maxconn;
48 else if (s->minconn == s->maxconn)
Willy Tarreau86034312006-12-29 00:10:33 +010049 /* static limit */
Willy Tarreau9909fc12007-11-30 17:42:05 +010050 max = s->maxconn;
51 else max = MAX(s->minconn,
52 s->proxy->beconn * s->maxconn / s->proxy->fullconn);
Willy Tarreau86034312006-12-29 00:10:33 +010053
Emeric Brun52a91d32017-08-31 14:41:55 +020054 if ((s->cur_state == SRV_ST_STARTING) &&
Willy Tarreau9909fc12007-11-30 17:42:05 +010055 now.tv_sec < s->last_change + s->slowstart &&
56 now.tv_sec >= s->last_change) {
57 unsigned int ratio;
Willy Tarreau28a9e522008-09-14 17:43:27 +020058 ratio = 100 * (now.tv_sec - s->last_change) / s->slowstart;
59 max = MAX(1, max * ratio / 100);
Willy Tarreau9909fc12007-11-30 17:42:05 +010060 }
61 return max;
Willy Tarreaubaaee002006-06-26 02:48:02 +020062}
63
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +010064/* Remove the pendconn from the server/proxy queue. At this stage, the
65 * connection is not really dequeued. It will be done during the
66 * process_stream. This function must be called by function owning the locks on
67 * the pendconn _AND_ the server/proxy. It also decreases the pending count.
68 *
69 * The caller must own the lock on the pendconn _AND_ the queue containing the
70 * pendconn. The pendconn must still be queued.
Christopher Fauletf3a55db2017-06-09 14:26:38 +020071 */
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +010072static void pendconn_unlink(struct pendconn *p)
73{
74 if (p->srv)
75 p->srv->nbpend--;
76 else
77 p->px->nbpend--;
78 HA_ATOMIC_SUB(&p->px->totpend, 1);
79 LIST_DEL(&p->list);
80 LIST_INIT(&p->list);
Christopher Fauletf3a55db2017-06-09 14:26:38 +020081}
82
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +010083/* Process the next pending connection from either a server or a proxy, and
Christopher Fauletfd83f0b2018-03-19 15:22:09 +010084 * returns a strictly positive value on success (see below). If no pending
85 * connection is found, 0 is returned. Note that neither <srv> nor <px> may be
86 * NULL. Priority is given to the oldest request in the queue if both <srv> and
87 * <px> have pending requests. This ensures that no request will be left
88 * unserved. The <px> queue is not considered if the server (or a tracked
89 * server) is not RUNNING, is disabled, or has a null weight (server going
90 * down). The <srv> queue is still considered in this case, because if some
91 * connections remain there, it means that some requests have been forced there
92 * after it was seen down (eg: due to option persist). The stream is
93 * immediately marked as "assigned", and both its <srv> and <srv_conn> are set
94 * to <srv>.
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +010095 *
96 * This function must only be called if the server queue _AND_ the proxy queue
Christopher Fauletfd83f0b2018-03-19 15:22:09 +010097 * are locked. Today it is only called by process_srv_queue. When a pending
98 * connection is dequeued, this function returns 1 if the pending connection can
99 * be handled by the current thread, else it returns 2.
Willy Tarreaubaaee002006-06-26 02:48:02 +0200100 */
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100101static int pendconn_process_next_strm(struct server *srv, struct proxy *px)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200102{
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100103 struct pendconn *p = NULL;
104 struct server *rsrv;
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100105 int remote;
Willy Tarreaud132f742010-08-06 10:08:23 +0200106
Willy Tarreau44267702011-10-28 15:35:33 +0200107 rsrv = srv->track;
Willy Tarreaud132f742010-08-06 10:08:23 +0200108 if (!rsrv)
109 rsrv = srv;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200110
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100111 if (srv->nbpend) {
112 list_for_each_entry(p, &srv->pendconns, list) {
113 if (!HA_SPIN_TRYLOCK(PENDCONN_LOCK, &p->lock))
114 goto ps_found;
115 }
116 p = NULL;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200117 }
Willy Tarreau7c669d72008-06-20 15:04:11 +0200118
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100119 ps_found:
120 if (srv_currently_usable(rsrv) && px->nbpend) {
121 struct pendconn *pp;
122
123 list_for_each_entry(pp, &px->pendconns, list) {
124 /* If the server pendconn is older than the proxy one,
125 * we process the server one. */
126 if (p && !tv_islt(&pp->strm->logs.tv_request, &p->strm->logs.tv_request))
127 goto pendconn_found;
128
129 if (!HA_SPIN_TRYLOCK(PENDCONN_LOCK, &pp->lock)) {
130 /* Let's switch from the server pendconn to the
131 * proxy pendconn. Don't forget to unlock the
132 * server pendconn, if any. */
133 if (p)
134 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
135 p = pp;
136 goto pendconn_found;
137 }
138 }
139 }
140
141 if (!p)
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100142 return 0;
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100143
144 pendconn_found:
145 pendconn_unlink(p);
146 p->strm_flags |= SF_ASSIGNED;
147 p->srv = srv;
148
Christopher Faulet29f77e82017-06-08 14:04:45 +0200149 HA_ATOMIC_ADD(&srv->served, 1);
Christopher Fauletff8abcd2017-06-02 15:33:24 +0200150 HA_ATOMIC_ADD(&srv->proxy->served, 1);
Willy Tarreau7c669d72008-06-20 15:04:11 +0200151 if (px->lbprm.server_take_conn)
152 px->lbprm.server_take_conn(srv);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100153 __stream_add_srv_conn(p->strm, srv);
Willy Tarreau7c669d72008-06-20 15:04:11 +0200154
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100155 remote = !(p->strm->task->thread_mask & tid_bit);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100156 task_wakeup(p->strm->task, TASK_WOKEN_RES);
157 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100158
159 /* Returns 1 if the current thread can process the stream, otherwise returns 2. */
160 return remote ? 2 : 1;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200161}
162
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100163/* Manages a server's connection queue. This function will try to dequeue as
Christopher Faulet87566c92017-06-06 10:34:51 +0200164 * many pending streams as possible, and wake them up.
165 */
166void process_srv_queue(struct server *s)
167{
168 struct proxy *p = s->proxy;
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100169 int maxconn, remote = 0;
Christopher Faulet87566c92017-06-06 10:34:51 +0200170
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100171 HA_SPIN_LOCK(PROXY_LOCK, &p->lock);
172 HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
Christopher Faulet87566c92017-06-06 10:34:51 +0200173 maxconn = srv_dynamic_maxconn(s);
174 while (s->served < maxconn) {
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100175 int ret = pendconn_process_next_strm(s, p);
176 if (!ret)
Christopher Faulet87566c92017-06-06 10:34:51 +0200177 break;
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100178 remote |= (ret == 2);
Christopher Faulet87566c92017-06-06 10:34:51 +0200179 }
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100180 HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
181 HA_SPIN_UNLOCK(PROXY_LOCK, &p->lock);
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100182
183 if (remote)
184 thread_want_sync();
Christopher Faulet87566c92017-06-06 10:34:51 +0200185}
186
Willy Tarreau87b09662015-04-03 00:22:06 +0200187/* Adds the stream <strm> to the pending connection list of server <strm>->srv
188 * or to the one of <strm>->proxy if srv is NULL. All counters and back pointers
Willy Tarreaubaaee002006-06-26 02:48:02 +0200189 * are updated accordingly. Returns NULL if no memory is available, otherwise the
Willy Tarreau87b09662015-04-03 00:22:06 +0200190 * pendconn itself. If the stream was already marked as served, its flag is
191 * cleared. It is illegal to call this function with a non-NULL strm->srv_conn.
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100192 *
193 * This function must be called by the stream itself, so in the context of
194 * process_stream.
Willy Tarreaubaaee002006-06-26 02:48:02 +0200195 */
Willy Tarreau87b09662015-04-03 00:22:06 +0200196struct pendconn *pendconn_add(struct stream *strm)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200197{
198 struct pendconn *p;
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100199 struct proxy *px;
200 struct server *srv;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200201
Willy Tarreaubafbe012017-11-24 17:34:44 +0100202 p = pool_alloc(pool_head_pendconn);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200203 if (!p)
204 return NULL;
205
Christopher Faulet8ba59142017-06-27 15:43:53 +0200206 srv = objt_server(strm->target);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100207 px = strm->be;
208
209 p->srv = NULL;
210 p->px = px;
211 p->strm = strm;
212 p->strm_flags = strm->flags;
213 HA_SPIN_INIT(&p->lock);
Willy Tarreau7c669d72008-06-20 15:04:11 +0200214
Christopher Faulet8ba59142017-06-27 15:43:53 +0200215 if ((strm->flags & SF_ASSIGNED) && srv) {
216 p->srv = srv;
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100217 HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100218 srv->nbpend++;
219 strm->logs.srv_queue_size += srv->nbpend;
220 if (srv->nbpend > srv->counters.nbpend_max)
221 srv->counters.nbpend_max = srv->nbpend;
Willy Tarreau827aee92011-03-10 16:55:02 +0100222 LIST_ADDQ(&srv->pendconns, &p->list);
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100223 HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100224 }
225 else {
226 HA_SPIN_LOCK(PROXY_LOCK, &px->lock);
227 px->nbpend++;
228 strm->logs.prx_queue_size += px->nbpend;
229 if (px->nbpend > px->be_counters.nbpend_max)
230 px->be_counters.nbpend_max = px->nbpend;
231 LIST_ADDQ(&px->pendconns, &p->list);
232 HA_SPIN_UNLOCK(PROXY_LOCK, &px->lock);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200233 }
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100234 HA_ATOMIC_ADD(&px->totpend, 1);
235 strm->pend_pos = p;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200236 return p;
237}
238
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200239/* Redistribute pending connections when a server goes down. The number of
240 * connections redistributed is returned.
241 */
242int pendconn_redistribute(struct server *s)
243{
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100244 struct pendconn *p, *pback;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200245 int xferred = 0;
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100246 int remote = 0;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200247
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100248 /* The REDISP option was specified. We will ignore cookie and force to
249 * balance or use the dispatcher. */
250 if ((s->proxy->options & (PR_O_REDISP|PR_O_PERSIST)) != PR_O_REDISP)
251 return 0;
252
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100253 HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100254 list_for_each_entry_safe(p, pback, &s->pendconns, list) {
255 if (p->strm_flags & SF_FORCE_PRST)
256 continue;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200257
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100258 if (HA_SPIN_TRYLOCK(PENDCONN_LOCK, &p->lock))
259 continue;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200260
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100261 /* it's left to the dispatcher to choose a server */
262 pendconn_unlink(p);
263 p->strm_flags &= ~(SF_DIRECT | SF_ASSIGNED | SF_ADDR_SET);
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200264
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100265 remote |= !(p->strm->task->thread_mask & tid_bit);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100266 task_wakeup(p->strm->task, TASK_WOKEN_RES);
267 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200268 }
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100269 HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100270
271 if (remote)
272 thread_want_sync();
273
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200274 return xferred;
275}
276
277/* Check for pending connections at the backend, and assign some of them to
278 * the server coming up. The server's weight is checked before being assigned
279 * connections it may not be able to handle. The total number of transferred
280 * connections is returned.
281 */
282int pendconn_grab_from_px(struct server *s)
283{
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100284 struct pendconn *p, *pback;
285 int maxconn, xferred = 0;
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100286 int remote = 0;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200287
Emeric Brun52a91d32017-08-31 14:41:55 +0200288 if (!srv_currently_usable(s))
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200289 return 0;
290
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100291 HA_SPIN_LOCK(PROXY_LOCK, &s->proxy->lock);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100292 maxconn = srv_dynamic_maxconn(s);
293 list_for_each_entry_safe(p, pback, &s->proxy->pendconns, list) {
294 if (s->maxconn && s->served + xferred >= maxconn)
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200295 break;
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100296
297 if (HA_SPIN_TRYLOCK(PENDCONN_LOCK, &p->lock))
298 continue;
299
300 pendconn_unlink(p);
301 p->srv = s;
302
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100303 remote |= !(p->strm->task->thread_mask & tid_bit);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100304 task_wakeup(p->strm->task, TASK_WOKEN_RES);
305 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
306 xferred++;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200307 }
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100308 HA_SPIN_UNLOCK(PROXY_LOCK, &s->proxy->lock);
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100309
310 if (remote)
311 thread_want_sync();
312
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200313 return xferred;
314}
315
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100316/* Try to dequeue pending connection attached to the stream <strm>. It must
317 * always exists here. If the pendconn is still linked to the server or the
318 * proxy queue, nothing is done and the function returns 1. Otherwise,
319 * <strm>->flags and <strm>->target are updated, the pendconn is released and 0
320 * is returned.
321 *
322 * This function must be called by the stream itself, so in the context of
323 * process_stream.
Willy Tarreaubaaee002006-06-26 02:48:02 +0200324 */
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100325int pendconn_dequeue(struct stream *strm)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200326{
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100327 struct pendconn *p;
328
329 if (unlikely(!strm->pend_pos)) {
330 /* unexpected case because it is called by the stream itself and
331 * only the stream can release a pendconn. So it is only
332 * possible if a pendconn is released by someone else or if the
333 * stream is supposed to be queued but without its associated
334 * pendconn. In both cases it is a bug! */
335 abort();
Christopher Faulet8ba59142017-06-27 15:43:53 +0200336 }
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100337 p = strm->pend_pos;
338 HA_SPIN_LOCK(PENDCONN_LOCK, &p->lock);
339
340 /* the pendconn is still linked to the server/proxy queue, so unlock it
341 * and go away. */
342 if (!LIST_ISEMPTY(&p->list)) {
343 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
344 return 1;
Christopher Faulet8ba59142017-06-27 15:43:53 +0200345 }
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100346
347 /* the pendconn must be dequeued now */
348 if (p->srv)
349 strm->target = &p->srv->obj_type;
350
351 strm->flags &= ~(SF_DIRECT | SF_ASSIGNED | SF_ADDR_SET);
352 strm->flags |= p->strm_flags & (SF_DIRECT | SF_ASSIGNED | SF_ADDR_SET);
353 strm->pend_pos = NULL;
354 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
Willy Tarreaubafbe012017-11-24 17:34:44 +0100355 pool_free(pool_head_pendconn, p);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100356 return 0;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200357}
358
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100359/* Release the pending connection <p>, and decreases the pending count if
360 * needed. The connection might have been queued to a specific server as well as
361 * to the proxy. The stream also gets marked unqueued. <p> must always be
362 * defined here. So it is the caller responsibility to check its existance.
363 *
364 * This function must be called by the stream itself, so in the context of
365 * process_stream.
366 */
367void pendconn_free(struct pendconn *p)
Christopher Faulet8ba59142017-06-27 15:43:53 +0200368{
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100369 struct stream *strm = p->strm;
370
371 HA_SPIN_LOCK(PENDCONN_LOCK, &p->lock);
372
373 /* The pendconn was already unlinked, just release it. */
374 if (LIST_ISEMPTY(&p->list))
375 goto release;
376
Christopher Faulet8ba59142017-06-27 15:43:53 +0200377 if (p->srv) {
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100378 HA_SPIN_LOCK(SERVER_LOCK, &p->srv->lock);
379 p->srv->nbpend--;
Christopher Faulet8ba59142017-06-27 15:43:53 +0200380 LIST_DEL(&p->list);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100381 HA_SPIN_UNLOCK(SERVER_LOCK, &p->srv->lock);
Christopher Faulet8ba59142017-06-27 15:43:53 +0200382 }
383 else {
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100384 HA_SPIN_LOCK(PROXY_LOCK, &p->px->lock);
385 p->px->nbpend--;
Christopher Faulet8ba59142017-06-27 15:43:53 +0200386 LIST_DEL(&p->list);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100387 HA_SPIN_UNLOCK(PROXY_LOCK, &p->px->lock);
Christopher Faulet8ba59142017-06-27 15:43:53 +0200388 }
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100389 HA_ATOMIC_SUB(&p->px->totpend, 1);
390
391 release:
392 strm->pend_pos = NULL;
393 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
Willy Tarreaubafbe012017-11-24 17:34:44 +0100394 pool_free(pool_head_pendconn, p);
Christopher Faulet8ba59142017-06-27 15:43:53 +0200395}
Willy Tarreaubaaee002006-06-26 02:48:02 +0200396
397/*
398 * Local variables:
399 * c-indent-level: 8
400 * c-basic-offset: 8
401 * End:
402 */