blob: e82bfccdf1dbd570123222d0274b634ad997fea9 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 * Server management functions.
3 *
Willy Tarreau7c669d72008-06-20 15:04:11 +02004 * Copyright 2000-2008 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
13#include <stdlib.h>
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020014
15#include <common/config.h>
Willy Tarreau7c669d72008-06-20 15:04:11 +020016#include <common/debug.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020017#include <common/memory.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020018
Willy Tarreaubaaee002006-06-26 02:48:02 +020019#include <types/capture.h>
Willy Tarreau55a8d0e2008-11-30 18:47:21 +010020#include <types/global.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020021
Willy Tarreau55a8d0e2008-11-30 18:47:21 +010022#include <proto/backend.h>
Willy Tarreau7341d942007-05-13 19:56:02 +020023#include <proto/buffers.h>
Willy Tarreau8d5d7f22007-01-21 19:16:41 +010024#include <proto/hdr_idx.h>
Willy Tarreau332f8bf2007-05-13 21:36:56 +020025#include <proto/log.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020026#include <proto/session.h>
Willy Tarreau55a8d0e2008-11-30 18:47:21 +010027#include <proto/proto_http.h>
28#include <proto/proto_tcp.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020029#include <proto/queue.h>
Willy Tarreau55a8d0e2008-11-30 18:47:21 +010030#include <proto/stream_interface.h>
31#include <proto/stream_sock.h>
32#include <proto/task.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020033
34
Willy Tarreauc6ca1a02007-05-13 19:43:47 +020035struct pool_head *pool2_session;
Willy Tarreauf54f8bd2008-11-23 19:53:55 +010036struct list sessions;
Willy Tarreaubaaee002006-06-26 02:48:02 +020037
38/*
39 * frees the context associated to a session. It must have been removed first.
40 */
41void session_free(struct session *s)
42{
Willy Tarreau4dbc4a22007-03-03 16:23:22 +010043 struct http_txn *txn = &s->txn;
Willy Tarreau632f5a72007-07-11 10:42:35 +020044 struct proxy *fe = s->fe;
Willy Tarreau62e4f1d2008-12-07 20:16:23 +010045 struct bref *bref, *back;
Willy Tarreau0f7562b2007-01-07 15:46:13 +010046
Willy Tarreaubaaee002006-06-26 02:48:02 +020047 if (s->pend_pos)
48 pendconn_free(s->pend_pos);
Willy Tarreau1e62de62008-11-11 20:20:02 +010049 if (s->srv) { /* there may be requests left pending in queue */
50 if (s->flags & SN_CURR_SESS) {
51 s->flags &= ~SN_CURR_SESS;
52 s->srv->cur_sess--;
53 }
Willy Tarreau7c669d72008-06-20 15:04:11 +020054 process_srv_queue(s->srv);
Willy Tarreau1e62de62008-11-11 20:20:02 +010055 }
Willy Tarreau7c669d72008-06-20 15:04:11 +020056 if (unlikely(s->srv_conn)) {
57 /* the session still has a reserved slot on a server, but
58 * it should normally be only the same as the one above,
59 * so this should not happen in fact.
60 */
61 sess_change_server(s, NULL);
62 }
63
Willy Tarreau48d63db2008-08-03 17:41:33 +020064 pool_free2(pool2_buffer, s->req);
65 pool_free2(pool2_buffer, s->rep);
Willy Tarreaubaaee002006-06-26 02:48:02 +020066
Willy Tarreau92fb9832007-10-16 17:34:28 +020067 if (fe) {
Willy Tarreau48d63db2008-08-03 17:41:33 +020068 pool_free2(fe->hdr_idx_pool, txn->hdr_idx.v);
Willy Tarreau41dff822007-01-01 23:32:30 +010069
Willy Tarreau92fb9832007-10-16 17:34:28 +020070 if (txn->rsp.cap != NULL) {
71 struct cap_hdr *h;
Willy Tarreau48d63db2008-08-03 17:41:33 +020072 for (h = fe->rsp_cap; h; h = h->next)
73 pool_free2(h->pool, txn->rsp.cap[h->index]);
Willy Tarreau92fb9832007-10-16 17:34:28 +020074 pool_free2(fe->rsp_cap_pool, txn->rsp.cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +020075 }
Willy Tarreau92fb9832007-10-16 17:34:28 +020076 if (txn->req.cap != NULL) {
77 struct cap_hdr *h;
Willy Tarreau48d63db2008-08-03 17:41:33 +020078 for (h = fe->req_cap; h; h = h->next)
79 pool_free2(h->pool, txn->req.cap[h->index]);
Willy Tarreau92fb9832007-10-16 17:34:28 +020080 pool_free2(fe->req_cap_pool, txn->req.cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +020081 }
Willy Tarreaubaaee002006-06-26 02:48:02 +020082 }
Willy Tarreau48d63db2008-08-03 17:41:33 +020083 pool_free2(pool2_requri, txn->uri);
84 pool_free2(pool2_capture, txn->cli_cookie);
85 pool_free2(pool2_capture, txn->srv_cookie);
Willy Tarreau62e4f1d2008-12-07 20:16:23 +010086
87 list_for_each_entry_safe(bref, back, &s->back_refs, users) {
88 LIST_DEL(&bref->users);
89 LIST_ADDQ(&LIST_ELEM(s->list.n, struct session *, list)->back_refs, &bref->users);
90 bref->ref = s->list.n;
91 }
Willy Tarreauf54f8bd2008-11-23 19:53:55 +010092 LIST_DEL(&s->list);
Willy Tarreauc6ca1a02007-05-13 19:43:47 +020093 pool_free2(pool2_session, s);
Willy Tarreau632f5a72007-07-11 10:42:35 +020094
95 /* We may want to free the maximum amount of pools if the proxy is stopping */
Willy Tarreau92fb9832007-10-16 17:34:28 +020096 if (fe && unlikely(fe->state == PR_STSTOPPED)) {
Willy Tarreau48d63db2008-08-03 17:41:33 +020097 pool_flush2(pool2_buffer);
98 pool_flush2(fe->hdr_idx_pool);
99 pool_flush2(pool2_requri);
100 pool_flush2(pool2_capture);
101 pool_flush2(pool2_session);
102 pool_flush2(fe->req_cap_pool);
103 pool_flush2(fe->rsp_cap_pool);
Willy Tarreau632f5a72007-07-11 10:42:35 +0200104 }
Willy Tarreauc6ca1a02007-05-13 19:43:47 +0200105}
106
107
108/* perform minimal intializations, report 0 in case of error, 1 if OK. */
109int init_session()
110{
Willy Tarreauf54f8bd2008-11-23 19:53:55 +0100111 LIST_INIT(&sessions);
Willy Tarreauc6ca1a02007-05-13 19:43:47 +0200112 pool2_session = create_pool("session", sizeof(struct session), MEM_F_SHARED);
113 return pool2_session != NULL;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200114}
115
Willy Tarreau30e71012007-11-26 20:15:35 +0100116void session_process_counters(struct session *s)
117{
Krzysztof Piotr Oledzki583bc962007-11-24 22:12:47 +0100118 unsigned long long bytes;
119
Willy Tarreau30e71012007-11-26 20:15:35 +0100120 if (s->req) {
Krzysztof Piotr Oledzki583bc962007-11-24 22:12:47 +0100121 bytes = s->req->total - s->logs.bytes_in;
Willy Tarreau30e71012007-11-26 20:15:35 +0100122 s->logs.bytes_in = s->req->total;
123 if (bytes) {
124 s->fe->bytes_in += bytes;
Krzysztof Piotr Oledzki583bc962007-11-24 22:12:47 +0100125
Willy Tarreau30e71012007-11-26 20:15:35 +0100126 if (s->be != s->fe)
127 s->be->bytes_in += bytes;
Krzysztof Piotr Oledzki583bc962007-11-24 22:12:47 +0100128
Willy Tarreau30e71012007-11-26 20:15:35 +0100129 if (s->srv)
130 s->srv->bytes_in += bytes;
131 }
Krzysztof Piotr Oledzki583bc962007-11-24 22:12:47 +0100132 }
133
Willy Tarreau30e71012007-11-26 20:15:35 +0100134 if (s->rep) {
Krzysztof Piotr Oledzki583bc962007-11-24 22:12:47 +0100135 bytes = s->rep->total - s->logs.bytes_out;
Willy Tarreau30e71012007-11-26 20:15:35 +0100136 s->logs.bytes_out = s->rep->total;
137 if (bytes) {
138 s->fe->bytes_out += bytes;
Krzysztof Piotr Oledzki583bc962007-11-24 22:12:47 +0100139
Willy Tarreau30e71012007-11-26 20:15:35 +0100140 if (s->be != s->fe)
141 s->be->bytes_out += bytes;
Krzysztof Piotr Oledzki583bc962007-11-24 22:12:47 +0100142
Willy Tarreau30e71012007-11-26 20:15:35 +0100143 if (s->srv)
144 s->srv->bytes_out += bytes;
145 }
Krzysztof Piotr Oledzki583bc962007-11-24 22:12:47 +0100146 }
147}
Willy Tarreaubaaee002006-06-26 02:48:02 +0200148
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100149/* This function is called with (si->state == SI_ST_CON) meaning that a
150 * connection was attempted and that the file descriptor is already allocated.
151 * We must check for establishment, error and abort. Possible output states
152 * are SI_ST_EST (established), SI_ST_CER (error), SI_ST_DIS (abort), and
153 * SI_ST_CON (no change). The function returns 0 if it switches to SI_ST_CER,
154 * otherwise 1.
155 */
156int sess_update_st_con_tcp(struct session *s, struct stream_interface *si)
157{
158 struct buffer *req = si->ob;
159 struct buffer *rep = si->ib;
160
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100161 /* If we got an error, or if nothing happened and the connection timed
162 * out, we must give up. The CER state handler will take care of retry
163 * attempts and error reports.
164 */
165 if (unlikely(si->flags & (SI_FL_EXP|SI_FL_ERR))) {
166 si->state = SI_ST_CER;
167 fd_delete(si->fd);
168
169 if (si->err_type)
170 return 0;
171
172 si->err_loc = s->srv;
173 if (si->flags & SI_FL_ERR)
174 si->err_type = SI_ET_CONN_ERR;
175 else
176 si->err_type = SI_ET_CONN_TO;
177 return 0;
178 }
179
180 /* OK, maybe we want to abort */
181 if (unlikely((req->flags & BF_SHUTW_NOW) ||
182 (rep->flags & BF_SHUTW) ||
183 ((req->flags & BF_SHUTR) && /* FIXME: this should not prevent a connection from establishing */
184 ((req->flags & BF_EMPTY && !(req->flags & BF_WRITE_ACTIVITY)) ||
185 s->be->options & PR_O_ABRT_CLOSE)))) {
186 /* give up */
187 si->shutw(si);
188 si->err_type |= SI_ET_CONN_ABRT;
189 si->err_loc = s->srv;
190 return 1;
191 }
192
193 /* we need to wait a bit more if there was no activity either */
194 if (!(req->flags & BF_WRITE_ACTIVITY))
195 return 1;
196
197 /* OK, this means that a connection succeeded. The caller will be
198 * responsible for handling the transition from CON to EST.
199 */
200 s->logs.t_connect = tv_ms_elapsed(&s->logs.tv_accept, &now);
201 si->state = SI_ST_EST;
202 si->err_type = SI_ET_NONE;
203 si->err_loc = NULL;
204 return 1;
205}
206
207/* This function is called with (si->state == SI_ST_CER) meaning that a
208 * previous connection attempt has failed and that the file descriptor
209 * has already been released. Possible causes include asynchronous error
210 * notification and time out. Possible output states are SI_ST_CLO when
211 * retries are exhausted, SI_ST_TAR when a delay is wanted before a new
212 * connection attempt, SI_ST_ASS when it's wise to retry on the same server,
213 * and SI_ST_REQ when an immediate redispatch is wanted. The buffers are
214 * marked as in error state. It returns 0.
215 */
216int sess_update_st_cer(struct session *s, struct stream_interface *si)
217{
218 /* we probably have to release last session from the server */
219 if (s->srv) {
220 if (s->flags & SN_CURR_SESS) {
221 s->flags &= ~SN_CURR_SESS;
222 s->srv->cur_sess--;
223 }
224 sess_change_server(s, NULL);
225 }
226
227 /* ensure that we have enough retries left */
228 s->conn_retries--;
229 if (s->conn_retries < 0) {
230 if (!si->err_type) {
231 si->err_type = SI_ET_CONN_ERR;
232 si->err_loc = s->srv;
233 }
234
235 if (s->srv)
236 s->srv->failed_conns++;
237 s->be->failed_conns++;
238 if (may_dequeue_tasks(s->srv, s->be))
239 process_srv_queue(s->srv);
240
241 /* shutw is enough so stop a connecting socket */
242 si->shutw(si);
243 si->ob->flags |= BF_WRITE_ERROR;
244 si->ib->flags |= BF_READ_ERROR;
245
246 si->state = SI_ST_CLO;
Willy Tarreau0cac36f2008-11-30 20:44:17 +0100247 if (s->srv_error)
248 s->srv_error(s, si);
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100249 return 0;
250 }
251
252 /* If the "redispatch" option is set on the backend, we are allowed to
253 * retry on another server for the last retry. In order to achieve this,
254 * we must mark the session unassigned, and eventually clear the DIRECT
255 * bit to ignore any persistence cookie. We won't count a retry nor a
256 * redispatch yet, because this will depend on what server is selected.
257 */
258 if (s->srv && s->conn_retries == 0 && s->be->options & PR_O_REDISP) {
259 if (may_dequeue_tasks(s->srv, s->be))
260 process_srv_queue(s->srv);
261
262 s->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET);
263 s->prev_srv = s->srv;
264 si->state = SI_ST_REQ;
265 } else {
266 if (s->srv)
267 s->srv->retries++;
268 s->be->retries++;
269 si->state = SI_ST_ASS;
270 }
271
272 if (si->flags & SI_FL_ERR) {
273 /* The error was an asynchronous connection error, and we will
274 * likely have to retry connecting to the same server, most
275 * likely leading to the same result. To avoid this, we wait
276 * one second before retrying.
277 */
278
279 if (!si->err_type)
280 si->err_type = SI_ET_CONN_ERR;
281
282 si->state = SI_ST_TAR;
283 si->exp = tick_add(now_ms, MS_TO_TICKS(1000));
284 return 0;
285 }
286 return 0;
287}
288
289/*
290 * This function handles the transition between the SI_ST_CON state and the
291 * SI_ST_EST state. It must only be called after switching from SI_ST_CON to
292 * SI_ST_EST.
293 */
294void sess_establish(struct session *s, struct stream_interface *si)
295{
296 struct buffer *req = si->ob;
297 struct buffer *rep = si->ib;
298
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100299 if (s->be->mode == PR_MODE_TCP) { /* let's allow immediate data connection in this case */
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100300 buffer_set_rlim(rep, BUFSIZE); /* no rewrite needed */
301
302 /* if the user wants to log as soon as possible, without counting
303 * bytes from the server, then this is the right moment. */
304 if (s->fe->to_log && !(s->logs.logwait & LW_BYTES)) {
305 s->logs.t_close = s->logs.t_connect; /* to get a valid end date */
Willy Tarreaua5555ec2008-11-30 19:02:32 +0100306 s->do_log(s);
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100307 }
308#ifdef CONFIG_HAP_TCPSPLICE
309 if ((s->fe->options & s->be->options) & PR_O_TCPSPLICE) {
310 /* TCP splicing supported by both FE and BE */
311 tcp_splice_splicefd(req->prod->fd, si->fd, 0);
312 }
313#endif
314 }
315 else {
316 rep->analysers |= AN_RTR_HTTP_HDR;
317 buffer_set_rlim(rep, BUFSIZE - MAXREWRITE); /* rewrite needed */
318 s->txn.rsp.msg_state = HTTP_MSG_RPBEFORE;
319 /* reset hdr_idx which was already initialized by the request.
320 * right now, the http parser does it.
321 * hdr_idx_init(&s->txn.hdr_idx);
322 */
323 }
324
325 rep->flags |= BF_READ_ATTACHED; /* producer is now attached */
326 req->wex = TICK_ETERNITY;
327}
328
329/* Update stream interface status for input states SI_ST_ASS, SI_ST_QUE, SI_ST_TAR.
330 * Other input states are simply ignored.
331 * Possible output states are SI_ST_CLO, SI_ST_TAR, SI_ST_ASS, SI_ST_REQ, SI_ST_CON.
332 * Flags must have previously been updated for timeouts and other conditions.
333 */
334void sess_update_stream_int(struct session *s, struct stream_interface *si)
335{
336 DPRINTF(stderr,"[%u] %s: sess=%p rq=%p, rp=%p, exp(r,w)=%u,%u rqf=%08x rpf=%08x rql=%d rpl=%d cs=%d ss=%d\n",
337 now_ms, __FUNCTION__,
338 s,
339 s->req, s->rep,
340 s->req->rex, s->rep->wex,
341 s->req->flags, s->rep->flags,
342 s->req->l, s->rep->l, s->rep->cons->state, s->req->cons->state);
343
344 if (si->state == SI_ST_ASS) {
345 /* Server assigned to connection request, we have to try to connect now */
346 int conn_err;
347
348 conn_err = connect_server(s);
349 if (conn_err == SN_ERR_NONE) {
350 /* state = SI_ST_CON now */
Willy Tarreau8f6457c2008-12-01 00:08:28 +0100351 if (s->srv)
352 s->srv->cum_sess++;
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100353 return;
354 }
355
356 /* We have received a synchronous error. We might have to
357 * abort, retry immediately or redispatch.
358 */
359 if (conn_err == SN_ERR_INTERNAL) {
360 if (!si->err_type) {
361 si->err_type = SI_ET_CONN_OTHER;
362 si->err_loc = s->srv;
363 }
364
365 if (s->srv)
366 s->srv->cum_sess++;
367 if (s->srv)
368 s->srv->failed_conns++;
369 s->be->failed_conns++;
370
371 /* release other sessions waiting for this server */
372 if (may_dequeue_tasks(s->srv, s->be))
373 process_srv_queue(s->srv);
374
375 /* Failed and not retryable. */
376 si->shutr(si);
377 si->shutw(si);
378 si->ob->flags |= BF_WRITE_ERROR;
379
380 s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
381
382 /* no session was ever accounted for this server */
383 si->state = SI_ST_CLO;
Willy Tarreau0cac36f2008-11-30 20:44:17 +0100384 if (s->srv_error)
385 s->srv_error(s, si);
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100386 return;
387 }
388
389 /* We are facing a retryable error, but we don't want to run a
390 * turn-around now, as the problem is likely a source port
391 * allocation problem, so we want to retry now.
392 */
393 si->state = SI_ST_CER;
394 si->flags &= ~SI_FL_ERR;
395 sess_update_st_cer(s, si);
396 /* now si->state is one of SI_ST_CLO, SI_ST_TAR, SI_ST_ASS, SI_ST_REQ */
397 return;
398 }
399 else if (si->state == SI_ST_QUE) {
400 /* connection request was queued, check for any update */
401 if (!s->pend_pos) {
402 /* The connection is not in the queue anymore. Either
403 * we have a server connection slot available and we
404 * go directly to the assigned state, or we need to
405 * load-balance first and go to the INI state.
406 */
407 si->exp = TICK_ETERNITY;
408 if (unlikely(!(s->flags & SN_ASSIGNED)))
409 si->state = SI_ST_REQ;
410 else {
411 s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
412 si->state = SI_ST_ASS;
413 }
414 return;
415 }
416
417 /* Connection request still in queue... */
418 if (si->flags & SI_FL_EXP) {
419 /* ... and timeout expired */
420 si->exp = TICK_ETERNITY;
421 s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
422 if (s->srv)
423 s->srv->failed_conns++;
424 s->be->failed_conns++;
425 si->shutr(si);
426 si->shutw(si);
427 si->ob->flags |= BF_WRITE_TIMEOUT;
428 if (!si->err_type)
429 si->err_type = SI_ET_QUEUE_TO;
430 si->state = SI_ST_CLO;
Willy Tarreau0cac36f2008-11-30 20:44:17 +0100431 if (s->srv_error)
432 s->srv_error(s, si);
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100433 return;
434 }
435
436 /* Connection remains in queue, check if we have to abort it */
437 if ((si->ob->flags & (BF_READ_ERROR|BF_SHUTW_NOW)) || /* abort requested */
438 ((si->ob->flags & BF_SHUTR) && /* empty and client stopped */
439 (si->ob->flags & BF_EMPTY || s->be->options & PR_O_ABRT_CLOSE))) {
440 /* give up */
441 si->exp = TICK_ETERNITY;
442 s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
443 si->shutr(si);
444 si->shutw(si);
445 si->err_type |= SI_ET_QUEUE_ABRT;
446 si->state = SI_ST_CLO;
Willy Tarreau0cac36f2008-11-30 20:44:17 +0100447 if (s->srv_error)
448 s->srv_error(s, si);
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100449 return;
450 }
451
452 /* Nothing changed */
453 return;
454 }
455 else if (si->state == SI_ST_TAR) {
456 /* Connection request might be aborted */
457 if ((si->ob->flags & (BF_READ_ERROR|BF_SHUTW_NOW)) || /* abort requested */
458 ((si->ob->flags & BF_SHUTR) && /* empty and client stopped */
459 (si->ob->flags & BF_EMPTY || s->be->options & PR_O_ABRT_CLOSE))) {
460 /* give up */
461 si->exp = TICK_ETERNITY;
462 si->shutr(si);
463 si->shutw(si);
464 si->err_type |= SI_ET_CONN_ABRT;
465 si->state = SI_ST_CLO;
Willy Tarreau0cac36f2008-11-30 20:44:17 +0100466 if (s->srv_error)
467 s->srv_error(s, si);
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100468 return;
469 }
470
471 if (!(si->flags & SI_FL_EXP))
472 return; /* still in turn-around */
473
474 si->exp = TICK_ETERNITY;
475
476 /* we keep trying on the same server as long as the session is
477 * marked "assigned".
478 * FIXME: Should we force a redispatch attempt when the server is down ?
479 */
480 if (s->flags & SN_ASSIGNED)
481 si->state = SI_ST_ASS;
482 else
483 si->state = SI_ST_REQ;
484 return;
485 }
486}
487
488/* This function initiates a server connection request on a stream interface
489 * already in SI_ST_REQ state. Upon success, the state goes to SI_ST_ASS,
490 * indicating that a server has been assigned. It may also return SI_ST_QUE,
491 * or SI_ST_CLO upon error.
492 */
493static void sess_prepare_conn_req(struct session *s, struct stream_interface *si) {
494 DPRINTF(stderr,"[%u] %s: sess=%p rq=%p, rp=%p, exp(r,w)=%u,%u rqf=%08x rpf=%08x rql=%d rpl=%d cs=%d ss=%d\n",
495 now_ms, __FUNCTION__,
496 s,
497 s->req, s->rep,
498 s->req->rex, s->rep->wex,
499 s->req->flags, s->rep->flags,
500 s->req->l, s->rep->l, s->rep->cons->state, s->req->cons->state);
501
502 if (si->state != SI_ST_REQ)
503 return;
504
505 /* Try to assign a server */
506 if (srv_redispatch_connect(s) != 0) {
507 /* We did not get a server. Either we queued the
508 * connection request, or we encountered an error.
509 */
510 if (si->state == SI_ST_QUE)
511 return;
512
513 /* we did not get any server, let's check the cause */
514 si->shutr(si);
515 si->shutw(si);
516 si->ob->flags |= BF_WRITE_ERROR;
517 if (!si->err_type)
518 si->err_type = SI_ET_CONN_OTHER;
519 si->state = SI_ST_CLO;
Willy Tarreau0cac36f2008-11-30 20:44:17 +0100520 if (s->srv_error)
521 s->srv_error(s, si);
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100522 return;
523 }
524
525 /* The server is assigned */
526 s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
527 si->state = SI_ST_ASS;
528}
529
530/* Processes the client, server, request and response jobs of a session task,
531 * then puts it back to the wait queue in a clean state, or cleans up its
532 * resources if it must be deleted. Returns in <next> the date the task wants
533 * to be woken up, or TICK_ETERNITY. In order not to call all functions for
534 * nothing too many times, the request and response buffers flags are monitored
535 * and each function is called only if at least another function has changed at
536 * least one flag it is interested in.
537 */
538void process_session(struct task *t, int *next)
539{
540 struct session *s = t->context;
541 int resync;
542 unsigned int rqf_last, rpf_last;
543
544 //DPRINTF(stderr, "%s:%d: cs=%d ss=%d(%d) rqf=0x%08x rpf=0x%08x\n", __FUNCTION__, __LINE__,
545 // s->si[0].state, s->si[1].state, s->si[1].err_type, s->req->flags, s->rep->flags);
546
547 /* 1a: Check for low level timeouts if needed. We just set a flag on
548 * stream interfaces when their timeouts have expired.
549 */
550 if (unlikely(t->state & TASK_WOKEN_TIMER)) {
551 stream_int_check_timeouts(&s->si[0]);
552 stream_int_check_timeouts(&s->si[1]);
553 buffer_check_timeouts(s->req);
554 buffer_check_timeouts(s->rep);
555 }
556
557 /* copy req/rep flags so that we can detect shutdowns */
558 rqf_last = s->req->flags;
559 rpf_last = s->rep->flags;
560
561 /* 1b: check for low-level errors reported at the stream interface.
562 * First we check if it's a retryable error (in which case we don't
563 * want to tell the buffer). Otherwise we report the error one level
564 * upper by setting flags into the buffers. Note that the side towards
565 * the client cannot have connect (hence retryable) errors. Also, the
566 * connection setup code must be able to deal with any type of abort.
567 */
568 if (unlikely(s->si[0].flags & SI_FL_ERR)) {
569 if (s->si[0].state == SI_ST_EST || s->si[0].state == SI_ST_DIS) {
570 s->si[0].shutr(&s->si[0]);
571 s->si[0].shutw(&s->si[0]);
572 stream_int_report_error(&s->si[0]);
573 }
574 }
575
576 if (unlikely(s->si[1].flags & SI_FL_ERR)) {
577 if (s->si[1].state == SI_ST_EST || s->si[1].state == SI_ST_DIS) {
578 s->si[1].shutr(&s->si[1]);
579 s->si[1].shutw(&s->si[1]);
580 stream_int_report_error(&s->si[1]);
581 s->be->failed_resp++;
582 if (s->srv)
583 s->srv->failed_resp++;
584 }
585 /* note: maybe we should process connection errors here ? */
586 }
587
588 if (s->si[1].state == SI_ST_CON) {
589 /* we were trying to establish a connection on the server side,
590 * maybe it succeeded, maybe it failed, maybe we timed out, ...
591 */
592 if (unlikely(!sess_update_st_con_tcp(s, &s->si[1])))
593 sess_update_st_cer(s, &s->si[1]);
594 else if (s->si[1].state == SI_ST_EST)
595 sess_establish(s, &s->si[1]);
596
597 /* state is now one of SI_ST_CON (still in progress), SI_ST_EST
598 * (established), SI_ST_DIS (abort), SI_ST_CLO (last error),
599 * SI_ST_ASS/SI_ST_TAR/SI_ST_REQ for retryable errors.
600 */
601 }
602
603 /* check buffer timeouts, and close the corresponding stream interfaces
604 * for future reads or writes. Note: this will also concern upper layers
605 * but we do not touch any other flag. We must be careful and correctly
606 * detect state changes when calling them.
607 */
608 if (unlikely(s->req->flags & (BF_READ_TIMEOUT|BF_WRITE_TIMEOUT))) {
609 if (s->req->flags & BF_READ_TIMEOUT)
610 s->req->prod->shutr(s->req->prod);
611 if (s->req->flags & BF_WRITE_TIMEOUT)
612 s->req->cons->shutw(s->req->cons);
613 DPRINTF(stderr,
614 "[%u] %s:%d: task=%p s=%p, sfl=0x%08x, rq=%p, rp=%p, exp(r,w)=%u,%u rqf=%08x rpf=%08x rql=%d rpl=%d cs=%d ss=%d, cet=0x%x set=0x%x retr=%d\n",
615 now_ms, __FUNCTION__, __LINE__,
616 t,
617 s, s->flags,
618 s->req, s->rep,
619 s->req->rex, s->rep->wex,
620 s->req->flags, s->rep->flags,
621 s->req->l, s->rep->l, s->rep->cons->state, s->req->cons->state,
622 s->rep->cons->err_type, s->req->cons->err_type,
623 s->conn_retries);
624 }
625
626 if (unlikely(s->rep->flags & (BF_READ_TIMEOUT|BF_WRITE_TIMEOUT))) {
627 if (s->rep->flags & BF_READ_TIMEOUT)
628 s->rep->prod->shutr(s->rep->prod);
629 if (s->rep->flags & BF_WRITE_TIMEOUT)
630 s->rep->cons->shutw(s->rep->cons);
631 DPRINTF(stderr,
632 "[%u] %s:%d: task=%p s=%p, sfl=0x%08x, rq=%p, rp=%p, exp(r,w)=%u,%u rqf=%08x rpf=%08x rql=%d rpl=%d cs=%d ss=%d, cet=0x%x set=0x%x retr=%d\n",
633 now_ms, __FUNCTION__, __LINE__,
634 t,
635 s, s->flags,
636 s->req, s->rep,
637 s->req->rex, s->rep->wex,
638 s->req->flags, s->rep->flags,
639 s->req->l, s->rep->l, s->rep->cons->state, s->req->cons->state,
640 s->rep->cons->err_type, s->req->cons->err_type,
641 s->conn_retries);
642 }
643
644 /* Check for connection closure */
645
646resync_stream_interface:
647 DPRINTF(stderr,
648 "[%u] %s:%d: task=%p s=%p, sfl=0x%08x, rq=%p, rp=%p, exp(r,w)=%u,%u rqf=%08x rpf=%08x rql=%d rpl=%d cs=%d ss=%d, cet=0x%x set=0x%x retr=%d\n",
649 now_ms, __FUNCTION__, __LINE__,
650 t,
651 s, s->flags,
652 s->req, s->rep,
653 s->req->rex, s->rep->wex,
654 s->req->flags, s->rep->flags,
655 s->req->l, s->rep->l, s->rep->cons->state, s->req->cons->state,
656 s->rep->cons->err_type, s->req->cons->err_type,
657 s->conn_retries);
658
659 /* nothing special to be done on client side */
660 if (unlikely(s->req->prod->state == SI_ST_DIS))
661 s->req->prod->state = SI_ST_CLO;
662
663 /* When a server-side connection is released, we have to count it and
664 * check for pending connections on this server.
665 */
666 if (unlikely(s->req->cons->state == SI_ST_DIS)) {
667 s->req->cons->state = SI_ST_CLO;
668 if (s->srv) {
669 if (s->flags & SN_CURR_SESS) {
670 s->flags &= ~SN_CURR_SESS;
671 s->srv->cur_sess--;
672 }
673 sess_change_server(s, NULL);
674 if (may_dequeue_tasks(s->srv, s->be))
675 process_srv_queue(s->srv);
676 }
677 }
678
679 /*
680 * Note: of the transient states (REQ, CER, DIS), only REQ may remain
681 * at this point.
682 */
683
684 /**** Process layer 7 below ****/
685
686 resync = 0;
687
688 /* Analyse request */
689 if ((s->req->flags & BF_MASK_ANALYSER) ||
690 (s->req->flags ^ rqf_last) & BF_MASK_STATIC) {
691 unsigned int flags = s->req->flags;
692
693 if (s->req->prod->state >= SI_ST_EST) {
694 /* it's up to the analysers to reset write_ena */
695 buffer_write_ena(s->req);
Willy Tarreauedcf6682008-11-30 23:15:34 +0100696
697 /* We will call all analysers for which a bit is set in
698 * s->req->analysers, following the bit order from LSB
699 * to MSB. The analysers must remove themselves from
700 * the list when not needed. This while() loop is in
701 * fact a cleaner if().
702 */
703 while (s->req->analysers) {
704 if (s->req->analysers & AN_REQ_INSPECT)
705 if (!tcp_inspect_request(s, s->req))
706 break;
707
Willy Tarreau59234e92008-11-30 23:51:27 +0100708 if (s->req->analysers & AN_REQ_HTTP_HDR)
709 if (!http_process_request(s, s->req))
Willy Tarreauedcf6682008-11-30 23:15:34 +0100710 break;
711
Willy Tarreau60b85b02008-11-30 23:28:40 +0100712 if (s->req->analysers & AN_REQ_HTTP_TARPIT)
713 if (!http_process_tarpit(s, s->req))
714 break;
715
Willy Tarreaud34af782008-11-30 23:36:37 +0100716 if (s->req->analysers & AN_REQ_HTTP_BODY)
717 if (!http_process_request_body(s, s->req))
718 break;
719
Willy Tarreauedcf6682008-11-30 23:15:34 +0100720 /* Just make sure that nobody set a wrong flag causing an endless loop */
721 s->req->analysers &= AN_REQ_INSPECT | AN_REQ_HTTP_HDR | AN_REQ_HTTP_TARPIT | AN_REQ_HTTP_BODY;
722
723 /* we don't want to loop anyway */
724 break;
725 }
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100726 }
727 s->req->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
728 flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
729 if (s->req->flags != flags)
730 resync = 1;
731 }
732
733 /* reflect what the L7 analysers have seen last */
734 rqf_last = s->req->flags;
735
736 /*
737 * Now forward all shutdown requests between both sides of the buffer
738 */
739
740 /* first, let's check if the request buffer needs to shutdown(write) */
741 if (unlikely((s->req->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_EMPTY|BF_HIJACK|BF_WRITE_ENA|BF_SHUTR)) ==
742 (BF_EMPTY|BF_WRITE_ENA|BF_SHUTR)))
743 buffer_shutw_now(s->req);
744 else if ((s->req->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_EMPTY|BF_WRITE_ENA)) == (BF_EMPTY|BF_WRITE_ENA) &&
745 (s->req->cons->state == SI_ST_EST) &&
746 s->be->options & PR_O_FORCE_CLO &&
747 s->rep->flags & BF_READ_ACTIVITY) {
748 /* We want to force the connection to the server to close,
749 * and the server has begun to respond. That's the right
750 * time.
751 */
752 buffer_shutw_now(s->req);
753 }
754
755 /* shutdown(write) pending */
756 if (unlikely((s->req->flags & (BF_SHUTW|BF_SHUTW_NOW)) == BF_SHUTW_NOW))
757 s->req->cons->shutw(s->req->cons);
758
759 /* shutdown(write) done on server side, we must stop the client too */
Willy Tarreau3dbc6942008-12-07 13:05:04 +0100760 if (unlikely((s->req->flags & (BF_SHUTW|BF_SHUTR|BF_SHUTR_NOW)) == BF_SHUTW &&
761 !s->req->analysers))
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100762 buffer_shutr_now(s->req);
763
764 /* shutdown(read) pending */
765 if (unlikely((s->req->flags & (BF_SHUTR|BF_SHUTR_NOW)) == BF_SHUTR_NOW))
766 s->req->prod->shutr(s->req->prod);
767
768 /* it's possible that an upper layer has requested a connection setup */
769 if (s->req->cons->state == SI_ST_INI &&
770 (s->req->flags & (BF_WRITE_ENA|BF_SHUTW|BF_SHUTW_NOW)) == BF_WRITE_ENA)
771 s->req->cons->state = SI_ST_REQ;
772
773 /* we may have a pending connection request, or a connection waiting
774 * for completion.
775 */
776 if (s->si[1].state >= SI_ST_REQ && s->si[1].state < SI_ST_CON) {
777 do {
778 /* nb: step 1 might switch from QUE to ASS, but we first want
779 * to give a chance to step 2 to perform a redirect if needed.
780 */
781 if (s->si[1].state != SI_ST_REQ)
782 sess_update_stream_int(s, &s->si[1]);
783 if (s->si[1].state == SI_ST_REQ)
784 sess_prepare_conn_req(s, &s->si[1]);
785
786 if (s->si[1].state == SI_ST_ASS && s->srv &&
787 s->srv->rdr_len && (s->flags & SN_REDIRECTABLE))
788 perform_http_redirect(s, &s->si[1]);
789 } while (s->si[1].state == SI_ST_ASS);
790 }
791
792 /*
793 * Here we want to check if we need to resync or not.
794 */
795 if ((s->req->flags ^ rqf_last) & BF_MASK_STATIC)
796 resync = 1;
797
798 s->req->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
799
800 /* according to benchmarks, it makes sense to resync now */
801 if (resync)
802 goto resync_stream_interface;
803
804
805 /* Analyse response */
806
807 if (unlikely(s->rep->flags & BF_HIJACK)) {
808 /* In inject mode, we wake up everytime something has
809 * happened on the write side of the buffer.
810 */
811 unsigned int flags = s->rep->flags;
812
813 if ((s->rep->flags & (BF_WRITE_PARTIAL|BF_WRITE_ERROR|BF_SHUTW)) &&
814 !(s->rep->flags & BF_FULL)) {
Willy Tarreau01bf8672008-12-07 18:03:29 +0100815 s->rep->hijacker(s, s->rep);
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100816 }
817 s->rep->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
818 flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
819 if (s->rep->flags != flags)
820 resync = 1;
821 }
822 else if ((s->rep->flags & BF_MASK_ANALYSER) ||
823 (s->rep->flags ^ rpf_last) & BF_MASK_STATIC) {
824 unsigned int flags = s->rep->flags;
825
826 if (s->rep->prod->state >= SI_ST_EST) {
827 /* it's up to the analysers to reset write_ena */
828 buffer_write_ena(s->rep);
829 if (s->rep->analysers)
830 process_response(s);
831 }
832 s->rep->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
833 flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
834 if (s->rep->flags != flags)
835 resync = 1;
836 }
837
838 /* reflect what the L7 analysers have seen last */
839 rpf_last = s->rep->flags;
840
841 /*
842 * Now forward all shutdown requests between both sides of the buffer
843 */
844
845 /*
846 * FIXME: this is probably where we should produce error responses.
847 */
848
849 /* first, let's check if the request buffer needs to shutdown(write) */
850 if (unlikely((s->rep->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_EMPTY|BF_HIJACK|BF_WRITE_ENA|BF_SHUTR)) ==
851 (BF_EMPTY|BF_WRITE_ENA|BF_SHUTR)))
852 buffer_shutw_now(s->rep);
853
854 /* shutdown(write) pending */
855 if (unlikely((s->rep->flags & (BF_SHUTW|BF_SHUTW_NOW)) == BF_SHUTW_NOW))
856 s->rep->cons->shutw(s->rep->cons);
857
858 /* shutdown(write) done on the client side, we must stop the server too */
Willy Tarreau3dbc6942008-12-07 13:05:04 +0100859 if (unlikely((s->rep->flags & (BF_SHUTW|BF_SHUTR|BF_SHUTR_NOW)) == BF_SHUTW) &&
860 !s->rep->analysers)
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100861 buffer_shutr_now(s->rep);
862
863 /* shutdown(read) pending */
864 if (unlikely((s->rep->flags & (BF_SHUTR|BF_SHUTR_NOW)) == BF_SHUTR_NOW))
865 s->rep->prod->shutr(s->rep->prod);
866
867 /*
868 * Here we want to check if we need to resync or not.
869 */
870 if ((s->rep->flags ^ rpf_last) & BF_MASK_STATIC)
871 resync = 1;
872
873 s->rep->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
874
875 if (resync)
876 goto resync_stream_interface;
877
878
879 /* This is needed only when debugging is enabled, to indicate
880 * client-side or server-side close. Please note that in the unlikely
881 * event where both sides would close at once, the sequence is reported
882 * on the server side first.
883 */
884 if (unlikely((global.mode & MODE_DEBUG) &&
885 (!(global.mode & MODE_QUIET) ||
886 (global.mode & MODE_VERBOSE)))) {
887 int len;
888
889 if (s->si[1].state == SI_ST_CLO &&
890 s->si[1].prev_state == SI_ST_EST) {
891 len = sprintf(trash, "%08x:%s.srvcls[%04x:%04x]\n",
892 s->uniq_id, s->be->id,
893 (unsigned short)s->si[0].fd,
894 (unsigned short)s->si[1].fd);
895 write(1, trash, len);
896 }
897
898 if (s->si[0].state == SI_ST_CLO &&
899 s->si[0].prev_state == SI_ST_EST) {
900 len = sprintf(trash, "%08x:%s.clicls[%04x:%04x]\n",
901 s->uniq_id, s->be->id,
902 (unsigned short)s->si[0].fd,
903 (unsigned short)s->si[1].fd);
904 write(1, trash, len);
905 }
906 }
907
908 if (likely((s->rep->cons->state != SI_ST_CLO) ||
909 (s->req->cons->state > SI_ST_INI && s->req->cons->state < SI_ST_CLO))) {
910
911 if ((s->fe->options & PR_O_CONTSTATS) && (s->flags & SN_BE_ASSIGNED))
912 session_process_counters(s);
913
914 if (s->rep->cons->state == SI_ST_EST)
Willy Tarreaub0253252008-11-30 21:37:12 +0100915 stream_sock_data_finish(s->rep->cons);
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100916
917 if (s->req->cons->state == SI_ST_EST)
Willy Tarreaub0253252008-11-30 21:37:12 +0100918 stream_sock_data_finish(s->req->cons);
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100919
920 s->req->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
921 s->rep->flags &= BF_CLEAR_READ & BF_CLEAR_WRITE & BF_CLEAR_TIMEOUT;
922 s->si[0].prev_state = s->si[0].state;
923 s->si[1].prev_state = s->si[1].state;
924 s->si[0].flags = s->si[1].flags = SI_FL_NONE;
925
926 /* Trick: if a request is being waiting for the server to respond,
927 * and if we know the server can timeout, we don't want the timeout
928 * to expire on the client side first, but we're still interested
929 * in passing data from the client to the server (eg: POST). Thus,
930 * we can cancel the client's request timeout if the server's
931 * request timeout is set and the server has not yet sent a response.
932 */
933
934 if ((s->rep->flags & (BF_WRITE_ENA|BF_SHUTR)) == 0 &&
935 (tick_isset(s->req->wex) || tick_isset(s->rep->rex)))
936 s->req->rex = TICK_ETERNITY;
937
938 t->expire = tick_first(tick_first(s->req->rex, s->req->wex),
939 tick_first(s->rep->rex, s->rep->wex));
940 if (s->req->analysers)
941 t->expire = tick_first(t->expire, s->req->analyse_exp);
942
943 if (s->si[0].exp)
944 t->expire = tick_first(t->expire, s->si[0].exp);
945
946 if (s->si[1].exp)
947 t->expire = tick_first(t->expire, s->si[1].exp);
948
949#ifdef DEBUG_FULL
950 fprintf(stderr, "[%u] queuing with exp=%u req->rex=%u req->wex=%u req->ana_exp=%u rep->rex=%u rep->wex=%u, cs=%d, ss=%d\n",
951 now_ms, t->expire, s->req->rex, s->req->wex, s->req->analyse_exp, s->rep->rex, s->rep->wex, s->si[0].state, s->si[1].state);
952#endif
953 /* restore t to its place in the task list */
954 task_queue(t);
955
956#ifdef DEBUG_DEV
957 /* this may only happen when no timeout is set or in case of an FSM bug */
958 if (!t->expire)
959 ABORT_NOW();
960#endif
961 *next = t->expire;
962 return; /* nothing more to do */
963 }
964
965 s->fe->feconn--;
966 if (s->flags & SN_BE_ASSIGNED)
967 s->be->beconn--;
968 actconn--;
969
970 if (unlikely((global.mode & MODE_DEBUG) &&
971 (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)))) {
972 int len;
973 len = sprintf(trash, "%08x:%s.closed[%04x:%04x] (term_trace=0x%08x)\n",
974 s->uniq_id, s->be->id,
975 (unsigned short)s->req->prod->fd, (unsigned short)s->req->cons->fd,
976 s->term_trace);
977 write(1, trash, len);
978 }
979
980 s->logs.t_close = tv_ms_elapsed(&s->logs.tv_accept, &now);
981 session_process_counters(s);
982
983 /* let's do a final log if we need it */
984 if (s->logs.logwait &&
985 !(s->flags & SN_MONITOR) &&
986 (!(s->fe->options & PR_O_NULLNOLOG) || s->req->total)) {
Willy Tarreaua5555ec2008-11-30 19:02:32 +0100987 s->do_log(s);
Willy Tarreau55a8d0e2008-11-30 18:47:21 +0100988 }
989
990 /* the task MUST not be in the run queue anymore */
991 task_delete(t);
992 session_free(s);
993 task_free(t);
994 *next = TICK_ETERNITY;
995}
996
Willy Tarreau7c669d72008-06-20 15:04:11 +0200997/*
998 * This function adjusts sess->srv_conn and maintains the previous and new
999 * server's served session counts. Setting newsrv to NULL is enough to release
1000 * current connection slot. This function also notifies any LB algo which might
1001 * expect to be informed about any change in the number of active sessions on a
1002 * server.
1003 */
1004void sess_change_server(struct session *sess, struct server *newsrv)
1005{
1006 if (sess->srv_conn == newsrv)
1007 return;
1008
1009 if (sess->srv_conn) {
1010 sess->srv_conn->served--;
1011 if (sess->srv_conn->proxy->lbprm.server_drop_conn)
1012 sess->srv_conn->proxy->lbprm.server_drop_conn(sess->srv_conn);
1013 sess->srv_conn = NULL;
1014 }
1015
1016 if (newsrv) {
1017 newsrv->served++;
1018 if (newsrv->proxy->lbprm.server_take_conn)
1019 newsrv->proxy->lbprm.server_take_conn(newsrv);
1020 sess->srv_conn = newsrv;
1021 }
1022}
1023
1024
Willy Tarreaubaaee002006-06-26 02:48:02 +02001025/*
1026 * Local variables:
1027 * c-indent-level: 8
1028 * c-basic-offset: 8
1029 * End:
1030 */