blob: c4f73664125330238d1f4728c18a6bb025bfb8c2 [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 */
Willy Tarreau9624fae2018-07-25 08:04:20 +020072static void __pendconn_unlink(struct pendconn *p)
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +010073{
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
Willy Tarreau9624fae2018-07-25 08:04:20 +020083/* Removes the pendconn from the server/proxy queue. At this stage, the
84 * connection is not really dequeued. It will be done during process_stream().
85 * This function takes all the required locks for the operation. The caller is
86 * responsible for ensuring that <p> is valid and still in the queue. Use
87 * pendconn_cond_unlink() if unsure. When the locks are already held, please
88 * use __pendconn_unlink() instead.
89 */
90void pendconn_unlink(struct pendconn *p)
91{
92 struct server __maybe_unused *sv;
93 struct proxy __maybe_unused *px;
94
95 HA_SPIN_LOCK(PENDCONN_LOCK, &p->lock);
96
97 px = p->px;
98 sv = p->srv;
99
100 if (sv)
101 HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
102 else
103 HA_SPIN_LOCK(PROXY_LOCK, &px->lock);
104
105 __pendconn_unlink(p);
106
107 if (sv)
108 HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
109 else
110 HA_SPIN_UNLOCK(PROXY_LOCK, &px->lock);
111
112 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
113}
114
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100115/* Process the next pending connection from either a server or a proxy, and
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100116 * returns a strictly positive value on success (see below). If no pending
117 * connection is found, 0 is returned. Note that neither <srv> nor <px> may be
118 * NULL. Priority is given to the oldest request in the queue if both <srv> and
119 * <px> have pending requests. This ensures that no request will be left
120 * unserved. The <px> queue is not considered if the server (or a tracked
121 * server) is not RUNNING, is disabled, or has a null weight (server going
122 * down). The <srv> queue is still considered in this case, because if some
123 * connections remain there, it means that some requests have been forced there
124 * after it was seen down (eg: due to option persist). The stream is
125 * immediately marked as "assigned", and both its <srv> and <srv_conn> are set
126 * to <srv>.
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100127 *
128 * This function must only be called if the server queue _AND_ the proxy queue
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100129 * are locked. Today it is only called by process_srv_queue. When a pending
130 * connection is dequeued, this function returns 1 if the pending connection can
131 * be handled by the current thread, else it returns 2.
Willy Tarreaubaaee002006-06-26 02:48:02 +0200132 */
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100133static int pendconn_process_next_strm(struct server *srv, struct proxy *px)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200134{
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100135 struct pendconn *p = NULL;
136 struct server *rsrv;
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100137 int remote;
Willy Tarreaud132f742010-08-06 10:08:23 +0200138
Willy Tarreau44267702011-10-28 15:35:33 +0200139 rsrv = srv->track;
Willy Tarreaud132f742010-08-06 10:08:23 +0200140 if (!rsrv)
141 rsrv = srv;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200142
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100143 if (srv->nbpend) {
144 list_for_each_entry(p, &srv->pendconns, list) {
145 if (!HA_SPIN_TRYLOCK(PENDCONN_LOCK, &p->lock))
146 goto ps_found;
147 }
148 p = NULL;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200149 }
Willy Tarreau7c669d72008-06-20 15:04:11 +0200150
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100151 ps_found:
152 if (srv_currently_usable(rsrv) && px->nbpend) {
153 struct pendconn *pp;
154
155 list_for_each_entry(pp, &px->pendconns, list) {
156 /* If the server pendconn is older than the proxy one,
157 * we process the server one. */
158 if (p && !tv_islt(&pp->strm->logs.tv_request, &p->strm->logs.tv_request))
159 goto pendconn_found;
160
161 if (!HA_SPIN_TRYLOCK(PENDCONN_LOCK, &pp->lock)) {
162 /* Let's switch from the server pendconn to the
163 * proxy pendconn. Don't forget to unlock the
164 * server pendconn, if any. */
165 if (p)
166 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
167 p = pp;
168 goto pendconn_found;
169 }
170 }
171 }
172
173 if (!p)
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100174 return 0;
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100175
176 pendconn_found:
Willy Tarreau9624fae2018-07-25 08:04:20 +0200177 __pendconn_unlink(p);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100178 p->strm_flags |= SF_ASSIGNED;
179 p->srv = srv;
180
Christopher Faulet29f77e82017-06-08 14:04:45 +0200181 HA_ATOMIC_ADD(&srv->served, 1);
Christopher Fauletff8abcd2017-06-02 15:33:24 +0200182 HA_ATOMIC_ADD(&srv->proxy->served, 1);
Willy Tarreau7c669d72008-06-20 15:04:11 +0200183 if (px->lbprm.server_take_conn)
184 px->lbprm.server_take_conn(srv);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100185 __stream_add_srv_conn(p->strm, srv);
Willy Tarreau7c669d72008-06-20 15:04:11 +0200186
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100187 remote = !(p->strm->task->thread_mask & tid_bit);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100188 task_wakeup(p->strm->task, TASK_WOKEN_RES);
189 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100190
191 /* Returns 1 if the current thread can process the stream, otherwise returns 2. */
192 return remote ? 2 : 1;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200193}
194
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100195/* Manages a server's connection queue. This function will try to dequeue as
Christopher Faulet87566c92017-06-06 10:34:51 +0200196 * many pending streams as possible, and wake them up.
197 */
198void process_srv_queue(struct server *s)
199{
200 struct proxy *p = s->proxy;
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100201 int maxconn, remote = 0;
Christopher Faulet87566c92017-06-06 10:34:51 +0200202
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100203 HA_SPIN_LOCK(PROXY_LOCK, &p->lock);
204 HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
Christopher Faulet87566c92017-06-06 10:34:51 +0200205 maxconn = srv_dynamic_maxconn(s);
206 while (s->served < maxconn) {
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100207 int ret = pendconn_process_next_strm(s, p);
208 if (!ret)
Christopher Faulet87566c92017-06-06 10:34:51 +0200209 break;
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100210 remote |= (ret == 2);
Christopher Faulet87566c92017-06-06 10:34:51 +0200211 }
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100212 HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
213 HA_SPIN_UNLOCK(PROXY_LOCK, &p->lock);
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100214
215 if (remote)
Ilya Shipitsin7741c852018-03-24 17:17:32 +0500216 THREAD_WANT_SYNC();
Christopher Faulet87566c92017-06-06 10:34:51 +0200217}
218
Willy Tarreau87b09662015-04-03 00:22:06 +0200219/* Adds the stream <strm> to the pending connection list of server <strm>->srv
220 * or to the one of <strm>->proxy if srv is NULL. All counters and back pointers
Willy Tarreaubaaee002006-06-26 02:48:02 +0200221 * are updated accordingly. Returns NULL if no memory is available, otherwise the
Willy Tarreau87b09662015-04-03 00:22:06 +0200222 * pendconn itself. If the stream was already marked as served, its flag is
223 * cleared. It is illegal to call this function with a non-NULL strm->srv_conn.
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100224 *
225 * This function must be called by the stream itself, so in the context of
226 * process_stream.
Willy Tarreaubaaee002006-06-26 02:48:02 +0200227 */
Willy Tarreau87b09662015-04-03 00:22:06 +0200228struct pendconn *pendconn_add(struct stream *strm)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200229{
230 struct pendconn *p;
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100231 struct proxy *px;
232 struct server *srv;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200233
Willy Tarreaubafbe012017-11-24 17:34:44 +0100234 p = pool_alloc(pool_head_pendconn);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200235 if (!p)
236 return NULL;
237
Christopher Faulet8ba59142017-06-27 15:43:53 +0200238 srv = objt_server(strm->target);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100239 px = strm->be;
240
241 p->srv = NULL;
242 p->px = px;
243 p->strm = strm;
244 p->strm_flags = strm->flags;
245 HA_SPIN_INIT(&p->lock);
Willy Tarreau7c669d72008-06-20 15:04:11 +0200246
Christopher Faulet8ba59142017-06-27 15:43:53 +0200247 if ((strm->flags & SF_ASSIGNED) && srv) {
248 p->srv = srv;
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100249 HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100250 srv->nbpend++;
251 strm->logs.srv_queue_size += srv->nbpend;
252 if (srv->nbpend > srv->counters.nbpend_max)
253 srv->counters.nbpend_max = srv->nbpend;
Willy Tarreau827aee92011-03-10 16:55:02 +0100254 LIST_ADDQ(&srv->pendconns, &p->list);
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100255 HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100256 }
257 else {
258 HA_SPIN_LOCK(PROXY_LOCK, &px->lock);
259 px->nbpend++;
260 strm->logs.prx_queue_size += px->nbpend;
261 if (px->nbpend > px->be_counters.nbpend_max)
262 px->be_counters.nbpend_max = px->nbpend;
263 LIST_ADDQ(&px->pendconns, &p->list);
264 HA_SPIN_UNLOCK(PROXY_LOCK, &px->lock);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200265 }
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100266 HA_ATOMIC_ADD(&px->totpend, 1);
267 strm->pend_pos = p;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200268 return p;
269}
270
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200271/* Redistribute pending connections when a server goes down. The number of
272 * connections redistributed is returned.
273 */
274int pendconn_redistribute(struct server *s)
275{
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100276 struct pendconn *p, *pback;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200277 int xferred = 0;
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100278 int remote = 0;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200279
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100280 /* The REDISP option was specified. We will ignore cookie and force to
281 * balance or use the dispatcher. */
282 if ((s->proxy->options & (PR_O_REDISP|PR_O_PERSIST)) != PR_O_REDISP)
283 return 0;
284
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100285 HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100286 list_for_each_entry_safe(p, pback, &s->pendconns, list) {
287 if (p->strm_flags & SF_FORCE_PRST)
288 continue;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200289
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100290 if (HA_SPIN_TRYLOCK(PENDCONN_LOCK, &p->lock))
291 continue;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200292
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100293 /* it's left to the dispatcher to choose a server */
Willy Tarreau9624fae2018-07-25 08:04:20 +0200294 __pendconn_unlink(p);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100295 p->strm_flags &= ~(SF_DIRECT | SF_ASSIGNED | SF_ADDR_SET);
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200296
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100297 remote |= !(p->strm->task->thread_mask & tid_bit);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100298 task_wakeup(p->strm->task, TASK_WOKEN_RES);
299 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200300 }
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100301 HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100302
303 if (remote)
Ilya Shipitsin7741c852018-03-24 17:17:32 +0500304 THREAD_WANT_SYNC();
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200305 return xferred;
306}
307
308/* Check for pending connections at the backend, and assign some of them to
309 * the server coming up. The server's weight is checked before being assigned
310 * connections it may not be able to handle. The total number of transferred
311 * connections is returned.
312 */
313int pendconn_grab_from_px(struct server *s)
314{
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100315 struct pendconn *p, *pback;
316 int maxconn, xferred = 0;
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100317 int remote = 0;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200318
Emeric Brun52a91d32017-08-31 14:41:55 +0200319 if (!srv_currently_usable(s))
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200320 return 0;
321
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100322 HA_SPIN_LOCK(PROXY_LOCK, &s->proxy->lock);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100323 maxconn = srv_dynamic_maxconn(s);
324 list_for_each_entry_safe(p, pback, &s->proxy->pendconns, list) {
325 if (s->maxconn && s->served + xferred >= maxconn)
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200326 break;
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100327
328 if (HA_SPIN_TRYLOCK(PENDCONN_LOCK, &p->lock))
329 continue;
330
Willy Tarreau9624fae2018-07-25 08:04:20 +0200331 __pendconn_unlink(p);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100332 p->srv = s;
333
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100334 remote |= !(p->strm->task->thread_mask & tid_bit);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100335 task_wakeup(p->strm->task, TASK_WOKEN_RES);
336 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
337 xferred++;
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200338 }
Christopher Faulet2a944ee2017-11-07 10:42:54 +0100339 HA_SPIN_UNLOCK(PROXY_LOCK, &s->proxy->lock);
Christopher Fauletfd83f0b2018-03-19 15:22:09 +0100340
341 if (remote)
Ilya Shipitsin7741c852018-03-24 17:17:32 +0500342 THREAD_WANT_SYNC();
Willy Tarreau4aac7db2014-05-16 11:48:10 +0200343 return xferred;
344}
345
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100346/* Try to dequeue pending connection attached to the stream <strm>. It must
347 * always exists here. If the pendconn is still linked to the server or the
348 * proxy queue, nothing is done and the function returns 1. Otherwise,
349 * <strm>->flags and <strm>->target are updated, the pendconn is released and 0
350 * is returned.
351 *
352 * This function must be called by the stream itself, so in the context of
353 * process_stream.
Willy Tarreaubaaee002006-06-26 02:48:02 +0200354 */
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100355int pendconn_dequeue(struct stream *strm)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200356{
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100357 struct pendconn *p;
358
359 if (unlikely(!strm->pend_pos)) {
360 /* unexpected case because it is called by the stream itself and
361 * only the stream can release a pendconn. So it is only
362 * possible if a pendconn is released by someone else or if the
363 * stream is supposed to be queued but without its associated
364 * pendconn. In both cases it is a bug! */
365 abort();
Christopher Faulet8ba59142017-06-27 15:43:53 +0200366 }
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100367 p = strm->pend_pos;
368 HA_SPIN_LOCK(PENDCONN_LOCK, &p->lock);
369
370 /* the pendconn is still linked to the server/proxy queue, so unlock it
371 * and go away. */
372 if (!LIST_ISEMPTY(&p->list)) {
373 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
374 return 1;
Christopher Faulet8ba59142017-06-27 15:43:53 +0200375 }
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100376
377 /* the pendconn must be dequeued now */
378 if (p->srv)
379 strm->target = &p->srv->obj_type;
380
381 strm->flags &= ~(SF_DIRECT | SF_ASSIGNED | SF_ADDR_SET);
382 strm->flags |= p->strm_flags & (SF_DIRECT | SF_ASSIGNED | SF_ADDR_SET);
383 strm->pend_pos = NULL;
384 HA_SPIN_UNLOCK(PENDCONN_LOCK, &p->lock);
Willy Tarreaubafbe012017-11-24 17:34:44 +0100385 pool_free(pool_head_pendconn, p);
Christopher Faulet5cd4bbd2018-03-14 16:18:06 +0100386 return 0;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200387}
388
Willy Tarreaubaaee002006-06-26 02:48:02 +0200389/*
390 * Local variables:
391 * c-indent-level: 8
392 * c-basic-offset: 8
393 * End:
394 */