blob: ea33240ad4fbdbf83b039d5ead9c5f6efb82b663 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 * Client-side variables and functions.
3 *
4 * Copyright 2000-2006 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 <errno.h>
14#include <fcntl.h>
15#include <stdio.h>
16#include <stdlib.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020017#include <string.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020018
19#include <sys/socket.h>
20#include <sys/stat.h>
21#include <sys/types.h>
22
Willy Tarreau2dd0d472006-06-29 17:53:05 +020023#include <common/compat.h>
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020024#include <common/config.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020025#include <common/time.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020026
27#include <types/backend.h>
28#include <types/buffers.h>
29#include <types/global.h>
30#include <types/httperr.h>
31#include <types/polling.h>
32#include <types/proxy.h>
33#include <types/server.h>
34#include <types/session.h>
35
Willy Tarreau54469402006-07-29 16:59:06 +020036#include <proto/buffers.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020037#include <proto/client.h>
38#include <proto/fd.h>
39#include <proto/log.h>
Willy Tarreaue5f20dc2006-12-03 15:21:35 +010040#include <proto/hdr_idx.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020041#include <proto/proto_http.h>
42#include <proto/stream_sock.h>
43#include <proto/task.h>
44
45
46
47/*
48 * FIXME: This should move to the STREAM_SOCK code then split into TCP and HTTP.
49 */
50
51/*
52 * this function is called on a read event from a listen socket, corresponding
53 * to an accept. It tries to accept as many connections as possible.
54 * It returns 0.
55 */
56int event_accept(int fd) {
57 struct proxy *p = (struct proxy *)fdtab[fd].owner;
58 struct session *s;
Willy Tarreauc2168d32007-03-03 20:51:44 +010059 struct http_txn *txn;
Willy Tarreaubaaee002006-06-26 02:48:02 +020060 struct task *t;
61 int cfd;
62 int max_accept;
63
64 if (global.nbproc > 1)
65 max_accept = 8; /* let other processes catch some connections too */
66 else
67 max_accept = -1;
68
Willy Tarreauf1221aa2006-12-17 22:14:12 +010069 while (p->feconn < p->maxconn && max_accept--) {
Willy Tarreaubaaee002006-06-26 02:48:02 +020070 struct sockaddr_storage addr;
71 socklen_t laddr = sizeof(addr);
72
73 if ((cfd = accept(fd, (struct sockaddr *)&addr, &laddr)) == -1) {
74 switch (errno) {
75 case EAGAIN:
76 case EINTR:
77 case ECONNABORTED:
78 return 0; /* nothing more to accept */
79 case ENFILE:
80 send_log(p, LOG_EMERG,
81 "Proxy %s reached system FD limit at %d. Please check system tunables.\n",
82 p->id, maxfd);
83 return 0;
84 case EMFILE:
85 send_log(p, LOG_EMERG,
86 "Proxy %s reached process FD limit at %d. Please check 'ulimit-n' and restart.\n",
87 p->id, maxfd);
88 return 0;
89 case ENOBUFS:
90 case ENOMEM:
91 send_log(p, LOG_EMERG,
92 "Proxy %s reached system memory limit at %d sockets. Please check system tunables.\n",
93 p->id, maxfd);
94 return 0;
95 default:
96 return 0;
97 }
98 }
99
100 if ((s = pool_alloc(session)) == NULL) { /* disable this proxy for a while */
101 Alert("out of memory in event_accept().\n");
Willy Tarreau2a429502006-10-15 14:52:29 +0200102 MY_FD_CLR(fd, StaticReadEvent);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200103 p->state = PR_STIDLE;
104 close(cfd);
105 return 0;
106 }
107
108 /* if this session comes from a known monitoring system, we want to ignore
109 * it as soon as possible, which means closing it immediately for TCP.
110 */
111 s->flags = 0;
112 if (addr.ss_family == AF_INET &&
113 p->mon_mask.s_addr &&
114 (((struct sockaddr_in *)&addr)->sin_addr.s_addr & p->mon_mask.s_addr) == p->mon_net.s_addr) {
115 if (p->mode == PR_MODE_TCP) {
116 close(cfd);
117 pool_free(session, s);
118 continue;
119 }
120 s->flags |= SN_MONITOR;
121 }
122
123 if ((t = pool_alloc(task)) == NULL) { /* disable this proxy for a while */
124 Alert("out of memory in event_accept().\n");
Willy Tarreau2a429502006-10-15 14:52:29 +0200125 MY_FD_CLR(fd, StaticReadEvent);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200126 p->state = PR_STIDLE;
127 close(cfd);
128 pool_free(session, s);
129 return 0;
130 }
131
132 s->cli_addr = addr;
133 if (cfd >= global.maxsock) {
134 Alert("accept(): not enough free sockets. Raise -n argument. Giving up.\n");
135 close(cfd);
136 pool_free(task, t);
137 pool_free(session, s);
138 return 0;
139 }
140
141 if ((fcntl(cfd, F_SETFL, O_NONBLOCK) == -1) ||
142 (setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY,
143 (char *) &one, sizeof(one)) == -1)) {
144 Alert("accept(): cannot set the socket in non blocking mode. Giving up\n");
145 close(cfd);
146 pool_free(task, t);
147 pool_free(session, s);
148 return 0;
149 }
150
151 if (p->options & PR_O_TCP_CLI_KA)
152 setsockopt(cfd, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(one));
153
Willy Tarreau964c9362007-01-07 00:38:00 +0100154 t->wq = NULL;
155 t->rqnext = NULL;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200156 t->state = TASK_IDLE;
157 t->process = process_session;
158 t->context = s;
159
160 s->task = t;
Willy Tarreau830ff452006-12-17 19:31:23 +0100161 s->be = s->fe = p;
Willy Tarreau73de9892006-11-30 11:40:23 +0100162
Willy Tarreaubaaee002006-06-26 02:48:02 +0200163 s->cli_state = (p->mode == PR_MODE_HTTP) ? CL_STHEADERS : CL_STDATA; /* no HTTP headers for non-HTTP proxies */
164 s->srv_state = SV_STIDLE;
165 s->req = s->rep = NULL; /* will be allocated later */
166
Willy Tarreaubaaee002006-06-26 02:48:02 +0200167 s->cli_fd = cfd;
168 s->srv_fd = -1;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200169 s->srv = NULL;
170 s->pend_pos = NULL;
Willy Tarreauddb358d2006-12-17 22:55:52 +0100171 s->conn_retries = p->beprm->conn_retries;
172
173 /* FIXME: the logs are horribly complicated now, because they are
174 * defined in <p>, <p->beprm>, and later <be> and <be->beprm>.
175 */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200176
177 if (s->flags & SN_MONITOR)
178 s->logs.logwait = 0;
179 else
180 s->logs.logwait = p->to_log;
181
182 s->logs.tv_accept = now;
183 s->logs.t_request = -1;
184 s->logs.t_queue = -1;
185 s->logs.t_connect = -1;
186 s->logs.t_data = -1;
187 s->logs.t_close = 0;
Willy Tarreau35d66b02007-01-02 00:28:21 +0100188 s->logs.bytes_in = s->logs.bytes_out = 0;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200189 s->logs.prx_queue_size = 0; /* we get the number of pending conns before us */
190 s->logs.srv_queue_size = 0; /* we will get this number soon */
191
192 s->data_source = DATA_SRC_NONE;
193
194 s->uniq_id = totalconn;
Willy Tarreauf1221aa2006-12-17 22:14:12 +0100195 p->cum_feconn++; /* cum_beconn will be increased once assigned */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200196
Willy Tarreauc2168d32007-03-03 20:51:44 +0100197 txn = &s->txn;
Willy Tarreau3d300592007-03-18 18:34:41 +0100198 txn->flags = 0;
Willy Tarreauc2168d32007-03-03 20:51:44 +0100199 txn->req.cap = NULL;
200 txn->rsp.cap = NULL;
201 txn->hdr_idx.v = NULL;
202 txn->hdr_idx.size = txn->hdr_idx.used = 0;
Willy Tarreau45e73e32006-12-17 00:05:15 +0100203
204 if (p->mode == PR_MODE_HTTP) {
Willy Tarreau3bac9ff2007-03-18 17:31:28 +0100205 txn->uri = NULL;
206 txn->cli_cookie = NULL;
207 txn->srv_cookie = NULL;
208 txn->status = -1;
209
Willy Tarreauc2168d32007-03-03 20:51:44 +0100210 txn->req.msg_state = HTTP_MSG_RQBEFORE; /* at the very beginning of the request */
211 txn->req.sol = txn->req.eol = NULL;
212 txn->req.som = txn->req.eoh = 0; /* relative to the buffer */
213 txn->auth_hdr.len = -1;
Willy Tarreau45e73e32006-12-17 00:05:15 +0100214
Willy Tarreauc2168d32007-03-03 20:51:44 +0100215 txn->hdr_idx.size = MAX_HTTP_HDR;
Willy Tarreau45e73e32006-12-17 00:05:15 +0100216
Willy Tarreau830ff452006-12-17 19:31:23 +0100217 if (p->fiprm->nb_req_cap > 0) {
Willy Tarreauc2168d32007-03-03 20:51:44 +0100218 if ((txn->req.cap =
Willy Tarreau830ff452006-12-17 19:31:23 +0100219 pool_alloc_from(p->fiprm->req_cap_pool, p->fiprm->nb_req_cap*sizeof(char *)))
Willy Tarreau45e73e32006-12-17 00:05:15 +0100220 == NULL) { /* no memory */
221 close(cfd); /* nothing can be done for this fd without memory */
222 pool_free(task, t);
223 pool_free(session, s);
224 return 0;
225 }
Willy Tarreauc2168d32007-03-03 20:51:44 +0100226 memset(txn->req.cap, 0, p->fiprm->nb_req_cap*sizeof(char *));
Willy Tarreaubaaee002006-06-26 02:48:02 +0200227 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200228
Willy Tarreau45e73e32006-12-17 00:05:15 +0100229
Willy Tarreau830ff452006-12-17 19:31:23 +0100230 if (p->fiprm->nb_rsp_cap > 0) {
Willy Tarreauc2168d32007-03-03 20:51:44 +0100231 if ((txn->rsp.cap =
Willy Tarreau830ff452006-12-17 19:31:23 +0100232 pool_alloc_from(p->fiprm->rsp_cap_pool, p->fiprm->nb_rsp_cap*sizeof(char *)))
Willy Tarreau45e73e32006-12-17 00:05:15 +0100233 == NULL) { /* no memory */
Willy Tarreauc2168d32007-03-03 20:51:44 +0100234 if (txn->req.cap != NULL)
235 pool_free_to(p->fiprm->req_cap_pool, txn->req.cap);
Willy Tarreau45e73e32006-12-17 00:05:15 +0100236 close(cfd); /* nothing can be done for this fd without memory */
237 pool_free(task, t);
238 pool_free(session, s);
239 return 0;
240 }
Willy Tarreauc2168d32007-03-03 20:51:44 +0100241 memset(txn->rsp.cap, 0, p->fiprm->nb_rsp_cap*sizeof(char *));
Willy Tarreaubaaee002006-06-26 02:48:02 +0200242 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200243
Willy Tarreau45e73e32006-12-17 00:05:15 +0100244
Willy Tarreauc2168d32007-03-03 20:51:44 +0100245 if ((txn->hdr_idx.v =
246 pool_alloc_from(p->hdr_idx_pool, txn->hdr_idx.size*sizeof(*txn->hdr_idx.v)))
Willy Tarreaue5f20dc2006-12-03 15:21:35 +0100247 == NULL) { /* no memory */
Willy Tarreauc2168d32007-03-03 20:51:44 +0100248 if (txn->rsp.cap != NULL)
249 pool_free_to(p->fiprm->rsp_cap_pool, txn->rsp.cap);
250 if (txn->req.cap != NULL)
251 pool_free_to(p->fiprm->req_cap_pool, txn->req.cap);
Willy Tarreaue5f20dc2006-12-03 15:21:35 +0100252 close(cfd); /* nothing can be done for this fd without memory */
253 pool_free(task, t);
254 pool_free(session, s);
255 return 0;
256 }
Willy Tarreauc2168d32007-03-03 20:51:44 +0100257 hdr_idx_init(&txn->hdr_idx);
Willy Tarreaue5f20dc2006-12-03 15:21:35 +0100258 }
259
Willy Tarreaubaaee002006-06-26 02:48:02 +0200260 if ((p->mode == PR_MODE_TCP || p->mode == PR_MODE_HTTP)
261 && (p->logfac1 >= 0 || p->logfac2 >= 0)) {
262 struct sockaddr_storage sockname;
263 socklen_t namelen = sizeof(sockname);
264
265 if (addr.ss_family != AF_INET ||
Willy Tarreau73de9892006-11-30 11:40:23 +0100266 !(s->fe->options & PR_O_TRANSP) ||
Willy Tarreaubaaee002006-06-26 02:48:02 +0200267 get_original_dst(cfd, (struct sockaddr_in *)&sockname, &namelen) == -1)
268 getsockname(cfd, (struct sockaddr *)&sockname, &namelen);
269
270 if (p->to_log) {
271 /* we have the client ip */
272 if (s->logs.logwait & LW_CLIP)
273 if (!(s->logs.logwait &= ~LW_CLIP))
274 sess_log(s);
275 }
276 else if (s->cli_addr.ss_family == AF_INET) {
277 char pn[INET_ADDRSTRLEN], sn[INET_ADDRSTRLEN];
278 if (inet_ntop(AF_INET, (const void *)&((struct sockaddr_in *)&sockname)->sin_addr,
279 sn, sizeof(sn)) &&
280 inet_ntop(AF_INET, (const void *)&((struct sockaddr_in *)&s->cli_addr)->sin_addr,
281 pn, sizeof(pn))) {
282 send_log(p, LOG_INFO, "Connect from %s:%d to %s:%d (%s/%s)\n",
283 pn, ntohs(((struct sockaddr_in *)&s->cli_addr)->sin_port),
284 sn, ntohs(((struct sockaddr_in *)&sockname)->sin_port),
285 p->id, (p->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
286 }
287 }
288 else {
289 char pn[INET6_ADDRSTRLEN], sn[INET6_ADDRSTRLEN];
290 if (inet_ntop(AF_INET6, (const void *)&((struct sockaddr_in6 *)&sockname)->sin6_addr,
291 sn, sizeof(sn)) &&
292 inet_ntop(AF_INET6, (const void *)&((struct sockaddr_in6 *)&s->cli_addr)->sin6_addr,
293 pn, sizeof(pn))) {
294 send_log(p, LOG_INFO, "Connect from %s:%d to %s:%d (%s/%s)\n",
295 pn, ntohs(((struct sockaddr_in6 *)&s->cli_addr)->sin6_port),
296 sn, ntohs(((struct sockaddr_in6 *)&sockname)->sin6_port),
297 p->id, (p->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
298 }
299 }
300 }
301
302 if ((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))) {
303 struct sockaddr_in sockname;
304 socklen_t namelen = sizeof(sockname);
305 int len;
306 if (addr.ss_family != AF_INET ||
Willy Tarreau73de9892006-11-30 11:40:23 +0100307 !(s->fe->options & PR_O_TRANSP) ||
Willy Tarreaubaaee002006-06-26 02:48:02 +0200308 get_original_dst(cfd, (struct sockaddr_in *)&sockname, &namelen) == -1)
309 getsockname(cfd, (struct sockaddr *)&sockname, &namelen);
310
311 if (s->cli_addr.ss_family == AF_INET) {
312 char pn[INET_ADDRSTRLEN];
313 inet_ntop(AF_INET,
314 (const void *)&((struct sockaddr_in *)&s->cli_addr)->sin_addr,
315 pn, sizeof(pn));
316
317 len = sprintf(trash, "%08x:%s.accept(%04x)=%04x from [%s:%d]\n",
318 s->uniq_id, p->id, (unsigned short)fd, (unsigned short)cfd,
319 pn, ntohs(((struct sockaddr_in *)&s->cli_addr)->sin_port));
320 }
321 else {
322 char pn[INET6_ADDRSTRLEN];
323 inet_ntop(AF_INET6,
324 (const void *)&((struct sockaddr_in6 *)(&s->cli_addr))->sin6_addr,
325 pn, sizeof(pn));
326
327 len = sprintf(trash, "%08x:%s.accept(%04x)=%04x from [%s:%d]\n",
328 s->uniq_id, p->id, (unsigned short)fd, (unsigned short)cfd,
329 pn, ntohs(((struct sockaddr_in6 *)(&s->cli_addr))->sin6_port));
330 }
331
332 write(1, trash, len);
333 }
334
335 if ((s->req = pool_alloc(buffer)) == NULL) { /* no memory */
Willy Tarreauc2168d32007-03-03 20:51:44 +0100336 if (txn->hdr_idx.v != NULL)
337 pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v);
338 if (txn->rsp.cap != NULL)
339 pool_free_to(p->fiprm->rsp_cap_pool, txn->rsp.cap);
340 if (txn->req.cap != NULL)
341 pool_free_to(p->fiprm->req_cap_pool, txn->req.cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200342 close(cfd); /* nothing can be done for this fd without memory */
343 pool_free(task, t);
344 pool_free(session, s);
345 return 0;
346 }
347
Willy Tarreau54469402006-07-29 16:59:06 +0200348 buffer_init(s->req);
349 s->req->rlim += BUFSIZE;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200350 if (s->cli_state == CL_STHEADERS) /* reserve some space for header rewriting */
351 s->req->rlim -= MAXREWRITE;
352
Willy Tarreau73de9892006-11-30 11:40:23 +0100353 s->req->rto = s->fe->clitimeout;
Willy Tarreau830ff452006-12-17 19:31:23 +0100354 s->req->wto = s->be->beprm->srvtimeout;
355 s->req->cto = s->be->beprm->srvtimeout;
Willy Tarreaud7971282006-07-29 18:36:34 +0200356
Willy Tarreaubaaee002006-06-26 02:48:02 +0200357 if ((s->rep = pool_alloc(buffer)) == NULL) { /* no memory */
358 pool_free(buffer, s->req);
Willy Tarreauc2168d32007-03-03 20:51:44 +0100359 if (txn->hdr_idx.v != NULL)
360 pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v);
361 if (txn->rsp.cap != NULL)
362 pool_free_to(p->fiprm->rsp_cap_pool, txn->rsp.cap);
363 if (txn->req.cap != NULL)
364 pool_free_to(p->fiprm->req_cap_pool, txn->req.cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200365 close(cfd); /* nothing can be done for this fd without memory */
366 pool_free(task, t);
367 pool_free(session, s);
368 return 0;
369 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200370
Willy Tarreau54469402006-07-29 16:59:06 +0200371 buffer_init(s->rep);
372
Willy Tarreau830ff452006-12-17 19:31:23 +0100373 s->rep->rto = s->be->beprm->srvtimeout;
374 s->rep->wto = s->fe->clitimeout;
Willy Tarreaud7971282006-07-29 18:36:34 +0200375 s->rep->cto = 0;
376
Willy Tarreaubaaee002006-06-26 02:48:02 +0200377 fdtab[cfd].owner = t;
378 fdtab[cfd].state = FD_STREADY;
Willy Tarreaud7971282006-07-29 18:36:34 +0200379 fdtab[cfd].cb[DIR_RD].f = &stream_sock_read;
Willy Tarreau54469402006-07-29 16:59:06 +0200380 fdtab[cfd].cb[DIR_RD].b = s->req;
Willy Tarreauf8306d52006-07-29 19:01:31 +0200381 fdtab[cfd].cb[DIR_WR].f = &stream_sock_write;
Willy Tarreau54469402006-07-29 16:59:06 +0200382 fdtab[cfd].cb[DIR_WR].b = s->rep;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200383
384 if ((p->mode == PR_MODE_HTTP && (s->flags & SN_MONITOR)) ||
Willy Tarreau0f772532006-12-23 20:51:41 +0100385 (p->mode == PR_MODE_HEALTH && (p->options & PR_O_HTTP_CHK))) {
Willy Tarreaubaaee002006-06-26 02:48:02 +0200386 /* Either we got a request from a monitoring system on an HTTP instance,
387 * or we're in health check mode with the 'httpchk' option enabled. In
388 * both cases, we return a fake "HTTP/1.0 200 OK" response and we exit.
389 */
Willy Tarreau0f772532006-12-23 20:51:41 +0100390 struct chunk msg = { .str = "HTTP/1.0 200 OK\r\n\r\n", .len = 19 };
391 client_retnclose(s, &msg); /* forge a 200 response */
392 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200393 else if (p->mode == PR_MODE_HEALTH) { /* health check mode, no client reading */
Willy Tarreau0f772532006-12-23 20:51:41 +0100394 struct chunk msg = { .str = "OK\n", .len = 3 };
395 client_retnclose(s, &msg); /* forge an "OK" response */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200396 }
397 else {
Willy Tarreau2a429502006-10-15 14:52:29 +0200398 MY_FD_SET(cfd, StaticReadEvent);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200399 }
400
401#if defined(DEBUG_FULL) && defined(ENABLE_EPOLL)
402 if (PrevReadEvent) {
Willy Tarreau2a429502006-10-15 14:52:29 +0200403 assert(!(MY_FD_ISSET(cfd, PrevReadEvent)));
404 assert(!(MY_FD_ISSET(cfd, PrevWriteEvent)));
Willy Tarreaubaaee002006-06-26 02:48:02 +0200405 }
406#endif
407 fd_insert(cfd);
408
Willy Tarreaud7971282006-07-29 18:36:34 +0200409 tv_eternity(&s->req->rex);
410 tv_eternity(&s->req->wex);
411 tv_eternity(&s->req->cex);
412 tv_eternity(&s->rep->rex);
413 tv_eternity(&s->rep->wex);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200414
Willy Tarreau73de9892006-11-30 11:40:23 +0100415 if (s->fe->clitimeout) {
Willy Tarreau2a429502006-10-15 14:52:29 +0200416 if (MY_FD_ISSET(cfd, StaticReadEvent))
Willy Tarreau73de9892006-11-30 11:40:23 +0100417 tv_delayfrom(&s->req->rex, &now, s->fe->clitimeout);
Willy Tarreau2a429502006-10-15 14:52:29 +0200418 if (MY_FD_ISSET(cfd, StaticWriteEvent))
Willy Tarreau73de9892006-11-30 11:40:23 +0100419 tv_delayfrom(&s->rep->wex, &now, s->fe->clitimeout);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200420 }
421
Willy Tarreaud7971282006-07-29 18:36:34 +0200422 tv_min(&t->expire, &s->req->rex, &s->rep->wex);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200423
424 task_queue(t);
425
426 if (p->mode != PR_MODE_HEALTH)
427 task_wakeup(&rq, t);
428
Willy Tarreauf1221aa2006-12-17 22:14:12 +0100429 p->feconn++; /* beconn will be increased later */
430 if (p->feconn > p->feconn_max)
431 p->feconn_max = p->feconn;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200432 actconn++;
433 totalconn++;
434
435 // fprintf(stderr, "accepting from %p => %d conn, %d total, task=%p\n", p, actconn, totalconn, t);
Willy Tarreauf1221aa2006-12-17 22:14:12 +0100436 } /* end of while (p->feconn < p->maxconn) */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200437 return 0;
438}
439
440
441
442/*
443 * Local variables:
444 * c-indent-level: 8
445 * c-basic-offset: 8
446 * End:
447 */