blob: 1a1ccca18a6bf3757791004e002163fd4cb0c0ec [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;
198 txn->req.cap = NULL;
199 txn->rsp.cap = NULL;
200 txn->hdr_idx.v = NULL;
201 txn->hdr_idx.size = txn->hdr_idx.used = 0;
Willy Tarreau45e73e32006-12-17 00:05:15 +0100202
203 if (p->mode == PR_MODE_HTTP) {
Willy Tarreau3bac9ff2007-03-18 17:31:28 +0100204 txn->uri = NULL;
205 txn->cli_cookie = NULL;
206 txn->srv_cookie = NULL;
207 txn->status = -1;
208
Willy Tarreauc2168d32007-03-03 20:51:44 +0100209 txn->req.msg_state = HTTP_MSG_RQBEFORE; /* at the very beginning of the request */
210 txn->req.sol = txn->req.eol = NULL;
211 txn->req.som = txn->req.eoh = 0; /* relative to the buffer */
212 txn->auth_hdr.len = -1;
Willy Tarreau45e73e32006-12-17 00:05:15 +0100213
Willy Tarreauc2168d32007-03-03 20:51:44 +0100214 txn->hdr_idx.size = MAX_HTTP_HDR;
Willy Tarreau45e73e32006-12-17 00:05:15 +0100215
Willy Tarreau830ff452006-12-17 19:31:23 +0100216 if (p->fiprm->nb_req_cap > 0) {
Willy Tarreauc2168d32007-03-03 20:51:44 +0100217 if ((txn->req.cap =
Willy Tarreau830ff452006-12-17 19:31:23 +0100218 pool_alloc_from(p->fiprm->req_cap_pool, p->fiprm->nb_req_cap*sizeof(char *)))
Willy Tarreau45e73e32006-12-17 00:05:15 +0100219 == NULL) { /* no memory */
220 close(cfd); /* nothing can be done for this fd without memory */
221 pool_free(task, t);
222 pool_free(session, s);
223 return 0;
224 }
Willy Tarreauc2168d32007-03-03 20:51:44 +0100225 memset(txn->req.cap, 0, p->fiprm->nb_req_cap*sizeof(char *));
Willy Tarreaubaaee002006-06-26 02:48:02 +0200226 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200227
Willy Tarreau45e73e32006-12-17 00:05:15 +0100228
Willy Tarreau830ff452006-12-17 19:31:23 +0100229 if (p->fiprm->nb_rsp_cap > 0) {
Willy Tarreauc2168d32007-03-03 20:51:44 +0100230 if ((txn->rsp.cap =
Willy Tarreau830ff452006-12-17 19:31:23 +0100231 pool_alloc_from(p->fiprm->rsp_cap_pool, p->fiprm->nb_rsp_cap*sizeof(char *)))
Willy Tarreau45e73e32006-12-17 00:05:15 +0100232 == NULL) { /* no memory */
Willy Tarreauc2168d32007-03-03 20:51:44 +0100233 if (txn->req.cap != NULL)
234 pool_free_to(p->fiprm->req_cap_pool, txn->req.cap);
Willy Tarreau45e73e32006-12-17 00:05:15 +0100235 close(cfd); /* nothing can be done for this fd without memory */
236 pool_free(task, t);
237 pool_free(session, s);
238 return 0;
239 }
Willy Tarreauc2168d32007-03-03 20:51:44 +0100240 memset(txn->rsp.cap, 0, p->fiprm->nb_rsp_cap*sizeof(char *));
Willy Tarreaubaaee002006-06-26 02:48:02 +0200241 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200242
Willy Tarreau45e73e32006-12-17 00:05:15 +0100243
Willy Tarreauc2168d32007-03-03 20:51:44 +0100244 if ((txn->hdr_idx.v =
245 pool_alloc_from(p->hdr_idx_pool, txn->hdr_idx.size*sizeof(*txn->hdr_idx.v)))
Willy Tarreaue5f20dc2006-12-03 15:21:35 +0100246 == NULL) { /* no memory */
Willy Tarreauc2168d32007-03-03 20:51:44 +0100247 if (txn->rsp.cap != NULL)
248 pool_free_to(p->fiprm->rsp_cap_pool, txn->rsp.cap);
249 if (txn->req.cap != NULL)
250 pool_free_to(p->fiprm->req_cap_pool, txn->req.cap);
Willy Tarreaue5f20dc2006-12-03 15:21:35 +0100251 close(cfd); /* nothing can be done for this fd without memory */
252 pool_free(task, t);
253 pool_free(session, s);
254 return 0;
255 }
Willy Tarreauc2168d32007-03-03 20:51:44 +0100256 hdr_idx_init(&txn->hdr_idx);
Willy Tarreaue5f20dc2006-12-03 15:21:35 +0100257 }
258
Willy Tarreaubaaee002006-06-26 02:48:02 +0200259 if ((p->mode == PR_MODE_TCP || p->mode == PR_MODE_HTTP)
260 && (p->logfac1 >= 0 || p->logfac2 >= 0)) {
261 struct sockaddr_storage sockname;
262 socklen_t namelen = sizeof(sockname);
263
264 if (addr.ss_family != AF_INET ||
Willy Tarreau73de9892006-11-30 11:40:23 +0100265 !(s->fe->options & PR_O_TRANSP) ||
Willy Tarreaubaaee002006-06-26 02:48:02 +0200266 get_original_dst(cfd, (struct sockaddr_in *)&sockname, &namelen) == -1)
267 getsockname(cfd, (struct sockaddr *)&sockname, &namelen);
268
269 if (p->to_log) {
270 /* we have the client ip */
271 if (s->logs.logwait & LW_CLIP)
272 if (!(s->logs.logwait &= ~LW_CLIP))
273 sess_log(s);
274 }
275 else if (s->cli_addr.ss_family == AF_INET) {
276 char pn[INET_ADDRSTRLEN], sn[INET_ADDRSTRLEN];
277 if (inet_ntop(AF_INET, (const void *)&((struct sockaddr_in *)&sockname)->sin_addr,
278 sn, sizeof(sn)) &&
279 inet_ntop(AF_INET, (const void *)&((struct sockaddr_in *)&s->cli_addr)->sin_addr,
280 pn, sizeof(pn))) {
281 send_log(p, LOG_INFO, "Connect from %s:%d to %s:%d (%s/%s)\n",
282 pn, ntohs(((struct sockaddr_in *)&s->cli_addr)->sin_port),
283 sn, ntohs(((struct sockaddr_in *)&sockname)->sin_port),
284 p->id, (p->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
285 }
286 }
287 else {
288 char pn[INET6_ADDRSTRLEN], sn[INET6_ADDRSTRLEN];
289 if (inet_ntop(AF_INET6, (const void *)&((struct sockaddr_in6 *)&sockname)->sin6_addr,
290 sn, sizeof(sn)) &&
291 inet_ntop(AF_INET6, (const void *)&((struct sockaddr_in6 *)&s->cli_addr)->sin6_addr,
292 pn, sizeof(pn))) {
293 send_log(p, LOG_INFO, "Connect from %s:%d to %s:%d (%s/%s)\n",
294 pn, ntohs(((struct sockaddr_in6 *)&s->cli_addr)->sin6_port),
295 sn, ntohs(((struct sockaddr_in6 *)&sockname)->sin6_port),
296 p->id, (p->mode == PR_MODE_HTTP) ? "HTTP" : "TCP");
297 }
298 }
299 }
300
301 if ((global.mode & MODE_DEBUG) && (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))) {
302 struct sockaddr_in sockname;
303 socklen_t namelen = sizeof(sockname);
304 int len;
305 if (addr.ss_family != AF_INET ||
Willy Tarreau73de9892006-11-30 11:40:23 +0100306 !(s->fe->options & PR_O_TRANSP) ||
Willy Tarreaubaaee002006-06-26 02:48:02 +0200307 get_original_dst(cfd, (struct sockaddr_in *)&sockname, &namelen) == -1)
308 getsockname(cfd, (struct sockaddr *)&sockname, &namelen);
309
310 if (s->cli_addr.ss_family == AF_INET) {
311 char pn[INET_ADDRSTRLEN];
312 inet_ntop(AF_INET,
313 (const void *)&((struct sockaddr_in *)&s->cli_addr)->sin_addr,
314 pn, sizeof(pn));
315
316 len = sprintf(trash, "%08x:%s.accept(%04x)=%04x from [%s:%d]\n",
317 s->uniq_id, p->id, (unsigned short)fd, (unsigned short)cfd,
318 pn, ntohs(((struct sockaddr_in *)&s->cli_addr)->sin_port));
319 }
320 else {
321 char pn[INET6_ADDRSTRLEN];
322 inet_ntop(AF_INET6,
323 (const void *)&((struct sockaddr_in6 *)(&s->cli_addr))->sin6_addr,
324 pn, sizeof(pn));
325
326 len = sprintf(trash, "%08x:%s.accept(%04x)=%04x from [%s:%d]\n",
327 s->uniq_id, p->id, (unsigned short)fd, (unsigned short)cfd,
328 pn, ntohs(((struct sockaddr_in6 *)(&s->cli_addr))->sin6_port));
329 }
330
331 write(1, trash, len);
332 }
333
334 if ((s->req = pool_alloc(buffer)) == NULL) { /* no memory */
Willy Tarreauc2168d32007-03-03 20:51:44 +0100335 if (txn->hdr_idx.v != NULL)
336 pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v);
337 if (txn->rsp.cap != NULL)
338 pool_free_to(p->fiprm->rsp_cap_pool, txn->rsp.cap);
339 if (txn->req.cap != NULL)
340 pool_free_to(p->fiprm->req_cap_pool, txn->req.cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200341 close(cfd); /* nothing can be done for this fd without memory */
342 pool_free(task, t);
343 pool_free(session, s);
344 return 0;
345 }
346
Willy Tarreau54469402006-07-29 16:59:06 +0200347 buffer_init(s->req);
348 s->req->rlim += BUFSIZE;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200349 if (s->cli_state == CL_STHEADERS) /* reserve some space for header rewriting */
350 s->req->rlim -= MAXREWRITE;
351
Willy Tarreau73de9892006-11-30 11:40:23 +0100352 s->req->rto = s->fe->clitimeout;
Willy Tarreau830ff452006-12-17 19:31:23 +0100353 s->req->wto = s->be->beprm->srvtimeout;
354 s->req->cto = s->be->beprm->srvtimeout;
Willy Tarreaud7971282006-07-29 18:36:34 +0200355
Willy Tarreaubaaee002006-06-26 02:48:02 +0200356 if ((s->rep = pool_alloc(buffer)) == NULL) { /* no memory */
357 pool_free(buffer, s->req);
Willy Tarreauc2168d32007-03-03 20:51:44 +0100358 if (txn->hdr_idx.v != NULL)
359 pool_free_to(p->hdr_idx_pool, txn->hdr_idx.v);
360 if (txn->rsp.cap != NULL)
361 pool_free_to(p->fiprm->rsp_cap_pool, txn->rsp.cap);
362 if (txn->req.cap != NULL)
363 pool_free_to(p->fiprm->req_cap_pool, txn->req.cap);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200364 close(cfd); /* nothing can be done for this fd without memory */
365 pool_free(task, t);
366 pool_free(session, s);
367 return 0;
368 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200369
Willy Tarreau54469402006-07-29 16:59:06 +0200370 buffer_init(s->rep);
371
Willy Tarreau830ff452006-12-17 19:31:23 +0100372 s->rep->rto = s->be->beprm->srvtimeout;
373 s->rep->wto = s->fe->clitimeout;
Willy Tarreaud7971282006-07-29 18:36:34 +0200374 s->rep->cto = 0;
375
Willy Tarreaubaaee002006-06-26 02:48:02 +0200376 fdtab[cfd].owner = t;
377 fdtab[cfd].state = FD_STREADY;
Willy Tarreaud7971282006-07-29 18:36:34 +0200378 fdtab[cfd].cb[DIR_RD].f = &stream_sock_read;
Willy Tarreau54469402006-07-29 16:59:06 +0200379 fdtab[cfd].cb[DIR_RD].b = s->req;
Willy Tarreauf8306d52006-07-29 19:01:31 +0200380 fdtab[cfd].cb[DIR_WR].f = &stream_sock_write;
Willy Tarreau54469402006-07-29 16:59:06 +0200381 fdtab[cfd].cb[DIR_WR].b = s->rep;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200382
383 if ((p->mode == PR_MODE_HTTP && (s->flags & SN_MONITOR)) ||
Willy Tarreau0f772532006-12-23 20:51:41 +0100384 (p->mode == PR_MODE_HEALTH && (p->options & PR_O_HTTP_CHK))) {
Willy Tarreaubaaee002006-06-26 02:48:02 +0200385 /* Either we got a request from a monitoring system on an HTTP instance,
386 * or we're in health check mode with the 'httpchk' option enabled. In
387 * both cases, we return a fake "HTTP/1.0 200 OK" response and we exit.
388 */
Willy Tarreau0f772532006-12-23 20:51:41 +0100389 struct chunk msg = { .str = "HTTP/1.0 200 OK\r\n\r\n", .len = 19 };
390 client_retnclose(s, &msg); /* forge a 200 response */
391 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200392 else if (p->mode == PR_MODE_HEALTH) { /* health check mode, no client reading */
Willy Tarreau0f772532006-12-23 20:51:41 +0100393 struct chunk msg = { .str = "OK\n", .len = 3 };
394 client_retnclose(s, &msg); /* forge an "OK" response */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200395 }
396 else {
Willy Tarreau2a429502006-10-15 14:52:29 +0200397 MY_FD_SET(cfd, StaticReadEvent);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200398 }
399
400#if defined(DEBUG_FULL) && defined(ENABLE_EPOLL)
401 if (PrevReadEvent) {
Willy Tarreau2a429502006-10-15 14:52:29 +0200402 assert(!(MY_FD_ISSET(cfd, PrevReadEvent)));
403 assert(!(MY_FD_ISSET(cfd, PrevWriteEvent)));
Willy Tarreaubaaee002006-06-26 02:48:02 +0200404 }
405#endif
406 fd_insert(cfd);
407
Willy Tarreaud7971282006-07-29 18:36:34 +0200408 tv_eternity(&s->req->rex);
409 tv_eternity(&s->req->wex);
410 tv_eternity(&s->req->cex);
411 tv_eternity(&s->rep->rex);
412 tv_eternity(&s->rep->wex);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200413
Willy Tarreau73de9892006-11-30 11:40:23 +0100414 if (s->fe->clitimeout) {
Willy Tarreau2a429502006-10-15 14:52:29 +0200415 if (MY_FD_ISSET(cfd, StaticReadEvent))
Willy Tarreau73de9892006-11-30 11:40:23 +0100416 tv_delayfrom(&s->req->rex, &now, s->fe->clitimeout);
Willy Tarreau2a429502006-10-15 14:52:29 +0200417 if (MY_FD_ISSET(cfd, StaticWriteEvent))
Willy Tarreau73de9892006-11-30 11:40:23 +0100418 tv_delayfrom(&s->rep->wex, &now, s->fe->clitimeout);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200419 }
420
Willy Tarreaud7971282006-07-29 18:36:34 +0200421 tv_min(&t->expire, &s->req->rex, &s->rep->wex);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200422
423 task_queue(t);
424
425 if (p->mode != PR_MODE_HEALTH)
426 task_wakeup(&rq, t);
427
Willy Tarreauf1221aa2006-12-17 22:14:12 +0100428 p->feconn++; /* beconn will be increased later */
429 if (p->feconn > p->feconn_max)
430 p->feconn_max = p->feconn;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200431 actconn++;
432 totalconn++;
433
434 // fprintf(stderr, "accepting from %p => %d conn, %d total, task=%p\n", p, actconn, totalconn, t);
Willy Tarreauf1221aa2006-12-17 22:14:12 +0100435 } /* end of while (p->feconn < p->maxconn) */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200436 return 0;
437}
438
439
440
441/*
442 * Local variables:
443 * c-indent-level: 8
444 * c-basic-offset: 8
445 * End:
446 */