blob: 55043692846894ac688bc123dd5d50b5f652c848 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 * Functions operating on SOCK_STREAM and buffers.
3 *
Willy Tarreau0c303ee2008-07-07 00:09:58 +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
Willy Tarreau6b4aad42009-01-18 21:59:13 +010013#define _GNU_SOURCE
Willy Tarreaubaaee002006-06-26 02:48:02 +020014#include <errno.h>
15#include <fcntl.h>
16#include <stdio.h>
17#include <stdlib.h>
18
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 Tarreaud6f087e2008-01-18 17:20:13 +010025#include <common/debug.h>
Willy Tarreau83749182007-04-15 20:56:27 +020026#include <common/standard.h>
Willy Tarreau0c303ee2008-07-07 00:09:58 +020027#include <common/ticks.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020028#include <common/time.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020029
Willy Tarreau2d212792008-08-27 21:41:35 +020030#include <proto/buffers.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020031#include <proto/client.h>
32#include <proto/fd.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020033#include <proto/stream_sock.h>
34#include <proto/task.h>
35
36
Willy Tarreau6b4aad42009-01-18 21:59:13 +010037/* On recent Linux kernels, the splice() syscall may be used for faster data copy.
38 * But it's not always defined on some OS versions, and it even happens that some
39 * definitions are wrong with some glibc due to an offset bug in syscall().
40 */
41
42#if defined(CONFIG_HAP_LINUX_SPLICE)
43#include <unistd.h>
44#include <sys/syscall.h>
45
46#ifndef SPLICE_F_MOVE
47#define SPLICE_F_MOVE 0x1
48#endif
49
50#ifndef SPLICE_F_NONBLOCK
51#define SPLICE_F_NONBLOCK 0x2
52#endif
53
54#ifndef SPLICE_F_MORE
55#define SPLICE_F_MORE 0x4
56#endif
57
58#ifndef __NR_splice
59#if defined(__powerpc__) || defined(__powerpc64__)
60#define __NR_splice 283
61#elif defined(__sparc__) || defined(__sparc64__)
62#define __NR_splice 232
63#elif defined(__x86_64__)
64#define __NR_splice 275
65#elif defined(__alpha__)
66#define __NR_splice 468
67#elif defined (__i386__)
68#define __NR_splice 313
69#else
70#warning unsupported architecture, guessing __NR_splice=313 like x86...
71#define __NR_splice 313
72#endif /* $arch */
73
74_syscall6(int, splice, int, fdin, loff_t *, off_in, int, fdout, loff_t *, off_out, size_t, len, unsigned long, flags)
75
76#endif /* __NR_splice */
77#endif /* CONFIG_HAP_LINUX_SPLICE */
78
79
Willy Tarreaubaaee002006-06-26 02:48:02 +020080/*
Willy Tarreaud7971282006-07-29 18:36:34 +020081 * this function is called on a read event from a stream socket.
Willy Tarreau83749182007-04-15 20:56:27 +020082 * It returns 0 if we have a high confidence that we will not be
83 * able to read more data without polling first. Returns non-zero
84 * otherwise.
Willy Tarreaubaaee002006-06-26 02:48:02 +020085 */
Willy Tarreaud7971282006-07-29 18:36:34 +020086int stream_sock_read(int fd) {
Willy Tarreaue5ed4062008-08-30 03:17:31 +020087 struct stream_interface *si = fdtab[fd].owner;
Willy Tarreau48adac52008-08-30 04:58:38 +020088 struct buffer *b = si->ib;
Willy Tarreau8a7af602008-05-03 23:07:14 +020089 int ret, max, retval, cur_read;
Willy Tarreaub8949f12007-03-23 22:39:59 +010090 int read_poll = MAX_READ_POLL_LOOPS;
Willy Tarreaubaaee002006-06-26 02:48:02 +020091
92#ifdef DEBUG_FULL
Willy Tarreaud6f087e2008-01-18 17:20:13 +010093 fprintf(stderr,"stream_sock_read : fd=%d, ev=0x%02x, owner=%p\n", fd, fdtab[fd].ev, fdtab[fd].owner);
Willy Tarreaubaaee002006-06-26 02:48:02 +020094#endif
95
Willy Tarreau83749182007-04-15 20:56:27 +020096 retval = 1;
97
Willy Tarreaud6f087e2008-01-18 17:20:13 +010098 /* stop immediately on errors */
99 if (fdtab[fd].state == FD_STERROR || (fdtab[fd].ev & FD_POLL_ERR))
Willy Tarreau6996e152007-04-30 14:37:43 +0200100 goto out_error;
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100101
102 /* stop here if we reached the end of data */
103 if ((fdtab[fd].ev & (FD_POLL_IN|FD_POLL_HUP)) == FD_POLL_HUP)
104 goto out_shutdown_r;
Willy Tarreau83749182007-04-15 20:56:27 +0200105
Willy Tarreau8a7af602008-05-03 23:07:14 +0200106 cur_read = 0;
Willy Tarreau6996e152007-04-30 14:37:43 +0200107 while (1) {
108 /*
109 * 1. compute the maximum block size we can read at once.
110 */
Willy Tarreau03d60bb2009-01-09 11:13:00 +0100111 if (b->l == 0) {
112 /* let's realign the buffer to optimize I/O */
113 b->r = b->w = b->lr = b->data;
114 max = b->max_len;
Willy Tarreau83749182007-04-15 20:56:27 +0200115 }
116 else if (b->r > b->w) {
Willy Tarreau03d60bb2009-01-09 11:13:00 +0100117 max = b->data + b->max_len - b->r;
Willy Tarreau83749182007-04-15 20:56:27 +0200118 }
119 else {
120 max = b->w - b->r;
Willy Tarreau03d60bb2009-01-09 11:13:00 +0100121 if (max > b->max_len)
122 max = b->max_len;
Willy Tarreau83749182007-04-15 20:56:27 +0200123 }
Willy Tarreau74ab2ac2008-11-23 17:23:07 +0100124
Willy Tarreau9c0fe592009-01-18 16:25:31 +0100125 if (max == 0) {
126 b->flags |= BF_FULL;
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100127 si->flags |= SI_FL_WAIT_ROOM;
Willy Tarreau9c0fe592009-01-18 16:25:31 +0100128 break;
129 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200130
Willy Tarreau6996e152007-04-30 14:37:43 +0200131 /*
132 * 2. read the largest possible block
133 */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200134#ifndef MSG_NOSIGNAL
Willy Tarreau83749182007-04-15 20:56:27 +0200135 {
136 int skerr;
137 socklen_t lskerr = sizeof(skerr);
138
139 ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &skerr, &lskerr);
140 if (ret == -1 || skerr)
141 ret = -1;
142 else
143 ret = recv(fd, b->r, max, 0);
144 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200145#else
Willy Tarreau83749182007-04-15 20:56:27 +0200146 ret = recv(fd, b->r, max, MSG_NOSIGNAL);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200147#endif
Willy Tarreau83749182007-04-15 20:56:27 +0200148 if (ret > 0) {
149 b->r += ret;
150 b->l += ret;
Willy Tarreau8a7af602008-05-03 23:07:14 +0200151 cur_read += ret;
Willy Tarreaub38903c2008-11-23 21:33:29 +0100152
Willy Tarreau0abebcc2009-01-08 00:09:41 +0100153 /* if we're allowed to directly forward data, we must update send_max */
154 if (b->to_forward > 0) {
155 int fwd = MIN(b->to_forward, ret);
156 b->send_max += fwd;
157 b->to_forward -= fwd;
158 }
Willy Tarreauf890dc92008-12-13 21:12:26 +0100159
Willy Tarreaub38903c2008-11-23 21:33:29 +0100160 if (fdtab[fd].state == FD_STCONN)
161 fdtab[fd].state = FD_STREADY;
162
Willy Tarreau3da77c52008-08-29 09:58:42 +0200163 b->flags |= BF_READ_PARTIAL;
Willy Tarreaue393fe22008-08-16 22:18:07 +0200164 b->flags &= ~BF_EMPTY;
Willy Tarreau74ab2ac2008-11-23 17:23:07 +0100165
Willy Tarreau83749182007-04-15 20:56:27 +0200166 if (b->r == b->data + BUFSIZE) {
167 b->r = b->data; /* wrap around the buffer */
168 }
Willy Tarreau9641e8f2007-03-23 23:02:09 +0100169
Willy Tarreau83749182007-04-15 20:56:27 +0200170 b->total += ret;
Willy Tarreau9641e8f2007-03-23 23:02:09 +0100171
Willy Tarreau03d60bb2009-01-09 11:13:00 +0100172 if (b->l >= b->max_len) {
Willy Tarreau6996e152007-04-30 14:37:43 +0200173 /* The buffer is now full, there's no point in going through
174 * the loop again.
175 */
Willy Tarreau8a7af602008-05-03 23:07:14 +0200176 if (!(b->flags & BF_STREAMER_FAST) && (cur_read == b->l)) {
177 b->xfer_small = 0;
178 b->xfer_large++;
179 if (b->xfer_large >= 3) {
180 /* we call this buffer a fast streamer if it manages
181 * to be filled in one call 3 consecutive times.
182 */
183 b->flags |= (BF_STREAMER | BF_STREAMER_FAST);
184 //fputc('+', stderr);
185 }
186 }
187 else if ((b->flags & (BF_STREAMER | BF_STREAMER_FAST)) &&
188 (cur_read <= BUFSIZE / 2)) {
189 b->xfer_large = 0;
190 b->xfer_small++;
191 if (b->xfer_small >= 2) {
192 /* if the buffer has been at least half full twice,
193 * we receive faster than we send, so at least it
194 * is not a "fast streamer".
195 */
196 b->flags &= ~BF_STREAMER_FAST;
197 //fputc('-', stderr);
198 }
199 }
200 else {
201 b->xfer_small = 0;
202 b->xfer_large = 0;
203 }
Willy Tarreau9c0fe592009-01-18 16:25:31 +0100204
205 b->flags |= BF_FULL;
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100206 si->flags |= SI_FL_WAIT_ROOM;
Willy Tarreau9c0fe592009-01-18 16:25:31 +0100207 break;
Willy Tarreau6996e152007-04-30 14:37:43 +0200208 }
209
Willy Tarreauab3e1d32007-06-03 14:10:36 +0200210 /* if too many bytes were missing from last read, it means that
211 * it's pointless trying to read again because the system does
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100212 * not have them in buffers. BTW, if FD_POLL_HUP was present,
213 * it means that we have reached the end and that the connection
214 * is closed.
Willy Tarreauab3e1d32007-06-03 14:10:36 +0200215 */
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100216 if (ret < max) {
Willy Tarreau8a7af602008-05-03 23:07:14 +0200217 if ((b->flags & (BF_STREAMER | BF_STREAMER_FAST)) &&
218 (cur_read <= BUFSIZE / 2)) {
219 b->xfer_large = 0;
220 b->xfer_small++;
221 if (b->xfer_small >= 3) {
222 /* we have read less than half of the buffer in
223 * one pass, and this happened at least 3 times.
224 * This is definitely not a streamer.
225 */
226 b->flags &= ~(BF_STREAMER | BF_STREAMER_FAST);
227 //fputc('!', stderr);
228 }
229 }
Willy Tarreau2bea3a12008-08-28 09:47:43 +0200230 /* unfortunately, on level-triggered events, POLL_HUP
231 * is generally delivered AFTER the system buffer is
232 * empty, so this one might never match.
233 */
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100234 if (fdtab[fd].ev & FD_POLL_HUP)
235 goto out_shutdown_r;
Willy Tarreau2bea3a12008-08-28 09:47:43 +0200236
237 /* if a streamer has read few data, it may be because we
238 * have exhausted system buffers. It's not worth trying
239 * again.
240 */
241 if (b->flags & BF_STREAMER)
242 break;
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100243 }
Willy Tarreauab3e1d32007-06-03 14:10:36 +0200244
245 /* generally if we read something smaller than 1 or 2 MSS,
Willy Tarreau2bea3a12008-08-28 09:47:43 +0200246 * it means that either we have exhausted the system's
247 * buffers (streamer or question-response protocol) or that
248 * the connection will be closed. Streamers are easily
249 * detected so we return early. For other cases, it's still
250 * better to perform a last read to be sure, because it may
251 * save one complete poll/read/wakeup cycle in case of shutdown.
Willy Tarreau83749182007-04-15 20:56:27 +0200252 */
Willy Tarreau2bea3a12008-08-28 09:47:43 +0200253 if (ret < MIN_RET_FOR_READ_LOOP && b->flags & BF_STREAMER)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200254 break;
Willy Tarreau83749182007-04-15 20:56:27 +0200255
Willy Tarreau6996e152007-04-30 14:37:43 +0200256 if (--read_poll <= 0)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200257 break;
Willy Tarreau83749182007-04-15 20:56:27 +0200258 }
259 else if (ret == 0) {
Willy Tarreau6996e152007-04-30 14:37:43 +0200260 /* connection closed */
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100261 goto out_shutdown_r;
Willy Tarreau83749182007-04-15 20:56:27 +0200262 }
Willy Tarreau9f195292007-04-15 21:26:58 +0200263 else if (errno == EAGAIN) {
264 /* Ignore EAGAIN but inform the poller that there is
Willy Tarreauaf78d0f2009-01-08 10:09:08 +0100265 * nothing to read left if we did not read much, ie
266 * less than what we were still expecting to read.
267 * But we may have done some work justifying to notify
268 * the task.
Willy Tarreau9f195292007-04-15 21:26:58 +0200269 */
Willy Tarreauaf78d0f2009-01-08 10:09:08 +0100270 if (cur_read < MIN_RET_FOR_READ_LOOP)
271 retval = 0;
Willy Tarreau83749182007-04-15 20:56:27 +0200272 break;
273 }
274 else {
Willy Tarreau6996e152007-04-30 14:37:43 +0200275 goto out_error;
Willy Tarreau83749182007-04-15 20:56:27 +0200276 }
Willy Tarreau6996e152007-04-30 14:37:43 +0200277 } /* while (1) */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200278
Willy Tarreau6996e152007-04-30 14:37:43 +0200279 out_wakeup:
Willy Tarreau9c0fe592009-01-18 16:25:31 +0100280 /* We might have some data the consumer is waiting for */
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100281 if ((b->send_max || b->splice_len) && (b->cons->flags & SI_FL_WAIT_DATA)) {
282 int last_len = b->splice_len;
283
Willy Tarreau3ffeba12008-12-14 14:42:35 +0100284 b->cons->chk_snd(b->cons);
285
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100286 /* check if the consumer has freed some space */
287 if (!(b->flags & BF_FULL) && (!last_len || b->splice_len < last_len))
288 si->flags &= ~SI_FL_WAIT_ROOM;
289 }
290
291 if (si->flags & SI_FL_WAIT_ROOM) {
Willy Tarreau9c0fe592009-01-18 16:25:31 +0100292 EV_FD_CLR(fd, DIR_RD);
293 b->rex = TICK_ETERNITY;
294 }
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100295 else if ((b->flags & (BF_READ_PARTIAL|BF_FULL|BF_READ_NOEXP)) == BF_READ_PARTIAL)
296 b->rex = tick_add_ifset(now_ms, b->rto);
Willy Tarreau9c0fe592009-01-18 16:25:31 +0100297
Willy Tarreau6b66f3e2008-12-14 17:31:54 +0100298 /* we have to wake up if there is a special event or if we don't have
299 * any more data to forward.
300 */
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100301 if ((b->flags & (BF_READ_NULL|BF_READ_ERROR|BF_SHUTR)) ||
302 !b->to_forward ||
303 si->state != SI_ST_EST ||
304 b->cons->state != SI_ST_EST ||
305 (si->flags & SI_FL_ERR))
Willy Tarreau6b66f3e2008-12-14 17:31:54 +0100306 task_wakeup(si->owner, TASK_WOKEN_IO);
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100307
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100308 fdtab[fd].ev &= ~FD_POLL_IN;
Willy Tarreau83749182007-04-15 20:56:27 +0200309 return retval;
Willy Tarreau6996e152007-04-30 14:37:43 +0200310
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100311 out_shutdown_r:
Willy Tarreaue5ed4062008-08-30 03:17:31 +0200312 /* we received a shutdown */
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100313 fdtab[fd].ev &= ~FD_POLL_HUP;
314 b->flags |= BF_READ_NULL;
Willy Tarreau99126c32008-11-27 10:30:51 +0100315 stream_sock_shutr(si);
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200316 goto out_wakeup;
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100317
Willy Tarreau6996e152007-04-30 14:37:43 +0200318 out_error:
Willy Tarreaucff64112008-11-03 06:26:53 +0100319 /* Read error on the file descriptor. We mark the FD as STERROR so
320 * that we don't use it anymore. The error is reported to the stream
321 * interface which will take proper action. We must not perturbate the
322 * buffer because the stream interface wants to ensure transparent
323 * connection retries.
Willy Tarreau6996e152007-04-30 14:37:43 +0200324 */
Willy Tarreaucff64112008-11-03 06:26:53 +0100325
Willy Tarreau6996e152007-04-30 14:37:43 +0200326 fdtab[fd].state = FD_STERROR;
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100327 fdtab[fd].ev &= ~FD_POLL_STICKY;
Willy Tarreaucff64112008-11-03 06:26:53 +0100328 si->flags |= SI_FL_ERR;
Willy Tarreau9c0fe592009-01-18 16:25:31 +0100329 retval = 1;
330 goto out_wakeup;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200331}
332
333
334/*
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100335 * This function is called to send buffer data to a stream socket.
336 * It returns -1 in case of unrecoverable error, 0 if the caller needs to poll
337 * before calling it again, otherwise 1.
Willy Tarreaubaaee002006-06-26 02:48:02 +0200338 */
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100339static int stream_sock_write_loop(struct stream_interface *si, struct buffer *b)
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100340{
Willy Tarreau83749182007-04-15 20:56:27 +0200341 int write_poll = MAX_WRITE_POLL_LOOPS;
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100342 int retval = 1;
343 int ret, max;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200344
Willy Tarreaud2def0f2009-01-18 17:37:33 +0100345 if (!b->send_max)
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100346 return retval;
Willy Tarreau83749182007-04-15 20:56:27 +0200347
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100348 /* when we're in this loop, we already know that there is no spliced
349 * data left, and that there are sendable buffered data.
350 */
Willy Tarreau6996e152007-04-30 14:37:43 +0200351 while (1) {
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100352 if (b->r > b->w)
Willy Tarreau83749182007-04-15 20:56:27 +0200353 max = b->r - b->w;
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100354 else
Willy Tarreau83749182007-04-15 20:56:27 +0200355 max = b->data + BUFSIZE - b->w;
Willy Tarreau83749182007-04-15 20:56:27 +0200356
Willy Tarreauf890dc92008-12-13 21:12:26 +0100357 /* limit the amount of outgoing data if required */
358 if (max > b->send_max)
359 max = b->send_max;
360
Willy Tarreaubaaee002006-06-26 02:48:02 +0200361#ifndef MSG_NOSIGNAL
362 {
363 int skerr;
364 socklen_t lskerr = sizeof(skerr);
365
Willy Tarreauc6423482006-10-15 14:59:03 +0200366 ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &skerr, &lskerr);
367 if (ret == -1 || skerr)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200368 ret = -1;
369 else
370 ret = send(fd, b->w, max, MSG_DONTWAIT);
371 }
372#else
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100373 ret = send(si->fd, b->w, max, MSG_DONTWAIT | MSG_NOSIGNAL);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200374#endif
375
376 if (ret > 0) {
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100377 if (fdtab[si->fd].state == FD_STCONN)
378 fdtab[si->fd].state = FD_STREADY;
Willy Tarreaub38903c2008-11-23 21:33:29 +0100379
Willy Tarreau3da77c52008-08-29 09:58:42 +0200380 b->flags |= BF_WRITE_PARTIAL;
Willy Tarreaue393fe22008-08-16 22:18:07 +0200381
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100382 b->w += ret;
383 if (b->w == b->data + BUFSIZE)
384 b->w = b->data; /* wrap around the buffer */
385
386 b->l -= ret;
387 if (likely(b->l < b->max_len))
Willy Tarreaue393fe22008-08-16 22:18:07 +0200388 b->flags &= ~BF_FULL;
Willy Tarreau74ab2ac2008-11-23 17:23:07 +0100389
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100390 if (likely(!b->l)) {
391 /* optimize data alignment in the buffer */
392 b->r = b->w = b->lr = b->data;
393 if (likely(!b->splice_len))
394 b->flags |= BF_EMPTY;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200395 }
Willy Tarreau83749182007-04-15 20:56:27 +0200396
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100397 b->send_max -= ret;
398 if (!b->send_max || !b->l)
399 break;
Willy Tarreau83749182007-04-15 20:56:27 +0200400
Willy Tarreauab3e1d32007-06-03 14:10:36 +0200401 /* if the system buffer is full, don't insist */
402 if (ret < max)
403 break;
404
Willy Tarreau6996e152007-04-30 14:37:43 +0200405 if (--write_poll <= 0)
406 break;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200407 }
Willy Tarreau6996e152007-04-30 14:37:43 +0200408 else if (ret == 0 || errno == EAGAIN) {
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100409 /* nothing written, we need to poll for write first */
Willy Tarreau83749182007-04-15 20:56:27 +0200410 retval = 0;
411 break;
412 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200413 else {
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100414 /* bad, we got an error */
415 retval = -1;
416 break;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200417 }
Willy Tarreau6996e152007-04-30 14:37:43 +0200418 } /* while (1) */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200419
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100420 return retval;
421}
Willy Tarreau6996e152007-04-30 14:37:43 +0200422
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100423
424/*
425 * This function is called on a write event from a stream socket.
426 * It returns 0 if the caller needs to poll before calling it again, otherwise
427 * non-zero.
428 */
429int stream_sock_write(int fd)
430{
431 struct stream_interface *si = fdtab[fd].owner;
432 struct buffer *b = si->ob;
433 int retval = 1;
434
435#ifdef DEBUG_FULL
436 fprintf(stderr,"stream_sock_write : fd=%d, owner=%p\n", fd, fdtab[fd].owner);
437#endif
438
439 retval = 1;
440 if (fdtab[fd].state == FD_STERROR || (fdtab[fd].ev & FD_POLL_ERR))
441 goto out_error;
442
443 if (likely(!(b->flags & BF_EMPTY))) {
444 /* OK there are data waiting to be sent */
445 retval = stream_sock_write_loop(si, b);
446 if (retval < 0)
447 goto out_error;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200448 }
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100449 else {
450 /* may be we have received a connection acknowledgement in TCP mode without data */
451 if (likely(fdtab[fd].state == FD_STCONN)) {
452 /* We have no data to send to check the connection, and
453 * getsockopt() will not inform us whether the connection
454 * is still pending. So we'll reuse connect() to check the
455 * state of the socket. This has the advantage of givig us
456 * the following info :
457 * - error
458 * - connecting (EALREADY, EINPROGRESS)
459 * - connected (EISCONN, 0)
460 */
461 if ((connect(fd, fdtab[fd].peeraddr, fdtab[fd].peerlen) == 0))
462 errno = 0;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200463
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100464 if (errno == EALREADY || errno == EINPROGRESS) {
465 retval = 0;
466 goto out_may_wakeup;
467 }
Willy Tarreau3ffeba12008-12-14 14:42:35 +0100468
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100469 if (errno && errno != EISCONN)
470 goto out_error;
Willy Tarreaufa7e1022008-10-19 07:30:41 +0200471
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100472 /* OK we just need to indicate that we got a connection
473 * and that we wrote nothing.
474 */
475 b->flags |= BF_WRITE_NULL;
476 fdtab[fd].state = FD_STREADY;
477 }
Willy Tarreau6996e152007-04-30 14:37:43 +0200478
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100479 /* Funny, we were called to write something but there wasn't
480 * anything. We can get there, for example if we were woken up
481 * on a write event to finish the splice, but the send_max is 0
482 * so we cannot write anything from the buffer. Let's disable
483 * the write event and pretend we never came there.
484 */
485 }
486
Willy Tarreaud2def0f2009-01-18 17:37:33 +0100487 if (!b->splice_len && !b->send_max) {
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100488 /* the connection is established but we can't write. Either the
489 * buffer is empty, or we just refrain from sending because the
490 * send_max limit was reached. Maybe we just wrote the last
491 * chunk and need to close.
492 */
493 if (((b->flags & (BF_SHUTW|BF_EMPTY|BF_HIJACK|BF_WRITE_ENA|BF_SHUTR)) ==
494 (BF_EMPTY|BF_WRITE_ENA|BF_SHUTR)) &&
495 (si->state == SI_ST_EST)) {
496 stream_sock_shutw(si);
497 goto out_wakeup;
498 }
499
500 if (b->flags & BF_EMPTY)
Willy Tarreauac128fe2009-01-09 13:05:19 +0100501 si->flags |= SI_FL_WAIT_DATA;
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100502
Willy Tarreauac128fe2009-01-09 13:05:19 +0100503 EV_FD_CLR(fd, DIR_WR);
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100504 b->wex = TICK_ETERNITY;
Willy Tarreauac128fe2009-01-09 13:05:19 +0100505 }
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100506
507 out_may_wakeup:
508 if (b->flags & BF_WRITE_ACTIVITY) {
509 /* update timeout if we have written something */
Willy Tarreaud2def0f2009-01-18 17:37:33 +0100510 if ((b->send_max || b->splice_len) &&
511 (b->flags & (BF_SHUTW|BF_WRITE_PARTIAL)) == BF_WRITE_PARTIAL)
Willy Tarreau0c2fc1f2009-01-18 15:30:37 +0100512 b->wex = tick_add_ifset(now_ms, b->wto);
513
514 out_wakeup:
515 if (tick_isset(si->ib->rex)) {
516 /* Note: to prevent the client from expiring read timeouts
517 * during writes, we refresh it. A better solution would be
518 * to merge read+write timeouts into a unique one, although
519 * that needs some study particularly on full-duplex TCP
520 * connections.
521 */
522 si->ib->rex = tick_add_ifset(now_ms, si->ib->rto);
523 }
524
525 /* the producer might be waiting for more room to store data */
526 if (likely((b->flags & (BF_WRITE_PARTIAL|BF_FULL)) == BF_WRITE_PARTIAL &&
527 (b->prod->flags & SI_FL_WAIT_ROOM)))
528 b->prod->chk_rcv(b->prod);
529
530 /* we have to wake up if there is a special event or if we don't have
531 * any more data to forward and it's not planned to send any more.
532 */
533 if (likely((b->flags & (BF_WRITE_NULL|BF_WRITE_ERROR|BF_SHUTW)) ||
534 (!b->to_forward && !b->send_max && !b->splice_len) ||
535 si->state != SI_ST_EST ||
536 b->prod->state != SI_ST_EST))
537 task_wakeup(si->owner, TASK_WOKEN_IO);
538 }
539
540 fdtab[fd].ev &= ~FD_POLL_OUT;
541 return retval;
Willy Tarreauac128fe2009-01-09 13:05:19 +0100542
Willy Tarreau6996e152007-04-30 14:37:43 +0200543 out_error:
Willy Tarreaucff64112008-11-03 06:26:53 +0100544 /* Write error on the file descriptor. We mark the FD as STERROR so
545 * that we don't use it anymore. The error is reported to the stream
546 * interface which will take proper action. We must not perturbate the
547 * buffer because the stream interface wants to ensure transparent
548 * connection retries.
Willy Tarreau6996e152007-04-30 14:37:43 +0200549 */
Willy Tarreaucff64112008-11-03 06:26:53 +0100550
Willy Tarreau6996e152007-04-30 14:37:43 +0200551 fdtab[fd].state = FD_STERROR;
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100552 fdtab[fd].ev &= ~FD_POLL_STICKY;
Willy Tarreaucff64112008-11-03 06:26:53 +0100553 si->flags |= SI_FL_ERR;
Willy Tarreaue5ed4062008-08-30 03:17:31 +0200554 task_wakeup(si->owner, TASK_WOKEN_IO);
555 return 1;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200556}
557
Willy Tarreau48adac52008-08-30 04:58:38 +0200558/*
Willy Tarreau3c6ab2e2008-09-04 11:19:41 +0200559 * This function performs a shutdown-write on a stream interface in a connected or
560 * init state (it does nothing for other states). It either shuts the write side
Willy Tarreau99126c32008-11-27 10:30:51 +0100561 * or closes the file descriptor and marks itself as closed. The buffer flags are
562 * updated to reflect the new state.
Willy Tarreau48adac52008-08-30 04:58:38 +0200563 */
Willy Tarreau0a5d5dd2008-11-23 19:31:35 +0100564void stream_sock_shutw(struct stream_interface *si)
Willy Tarreau48adac52008-08-30 04:58:38 +0200565{
Willy Tarreau99126c32008-11-27 10:30:51 +0100566 if (si->ob->flags & BF_SHUTW)
567 return;
568 si->ob->flags |= BF_SHUTW;
569 si->ob->wex = TICK_ETERNITY;
Willy Tarreaub0ef7352008-12-14 13:26:20 +0100570 si->flags &= ~SI_FL_WAIT_DATA;
Willy Tarreau99126c32008-11-27 10:30:51 +0100571
Willy Tarreaub38903c2008-11-23 21:33:29 +0100572 switch (si->state) {
Willy Tarreaub38903c2008-11-23 21:33:29 +0100573 case SI_ST_EST:
574 if (!(si->ib->flags & BF_SHUTR)) {
575 EV_FD_CLR(si->fd, DIR_WR);
576 shutdown(si->fd, SHUT_WR);
577 return;
578 }
579 /* fall through */
580 case SI_ST_CON:
Willy Tarreaub0ef7352008-12-14 13:26:20 +0100581 si->flags &= ~SI_FL_WAIT_ROOM;
Willy Tarreau8bfa4262008-11-27 09:25:45 +0100582 /* we may have to close a pending connection, and mark the
583 * response buffer as shutr
584 */
Willy Tarreau48adac52008-08-30 04:58:38 +0200585 fd_delete(si->fd);
Willy Tarreaufe3718a2008-11-30 18:14:12 +0100586 /* fall through */
587 case SI_ST_CER:
Willy Tarreau7f006512008-12-07 14:04:04 +0100588 si->state = SI_ST_DIS;
589 default:
Willy Tarreau99126c32008-11-27 10:30:51 +0100590 si->ib->flags |= BF_SHUTR;
Willy Tarreaufe3718a2008-11-30 18:14:12 +0100591 si->ib->rex = TICK_ETERNITY;
Willy Tarreau0a5d5dd2008-11-23 19:31:35 +0100592 return;
Willy Tarreau48adac52008-08-30 04:58:38 +0200593 }
Willy Tarreau48adac52008-08-30 04:58:38 +0200594}
Willy Tarreaubaaee002006-06-26 02:48:02 +0200595
Willy Tarreau2d212792008-08-27 21:41:35 +0200596/*
Willy Tarreau3c6ab2e2008-09-04 11:19:41 +0200597 * This function performs a shutdown-read on a stream interface in a connected or
Willy Tarreau0a5d5dd2008-11-23 19:31:35 +0100598 * init state (it does nothing for other states). It either shuts the read side
Willy Tarreau99126c32008-11-27 10:30:51 +0100599 * or closes the file descriptor and marks itself as closed. The buffer flags are
600 * updated to reflect the new state.
Willy Tarreau3c6ab2e2008-09-04 11:19:41 +0200601 */
Willy Tarreau0a5d5dd2008-11-23 19:31:35 +0100602void stream_sock_shutr(struct stream_interface *si)
Willy Tarreau3c6ab2e2008-09-04 11:19:41 +0200603{
Willy Tarreau99126c32008-11-27 10:30:51 +0100604 if (si->ib->flags & BF_SHUTR)
605 return;
606 si->ib->flags |= BF_SHUTR;
607 si->ib->rex = TICK_ETERNITY;
Willy Tarreaub0ef7352008-12-14 13:26:20 +0100608 si->flags &= ~SI_FL_WAIT_ROOM;
Willy Tarreau99126c32008-11-27 10:30:51 +0100609
Willy Tarreau8bfa4262008-11-27 09:25:45 +0100610 if (si->state != SI_ST_EST && si->state != SI_ST_CON)
Willy Tarreau0a5d5dd2008-11-23 19:31:35 +0100611 return;
Willy Tarreau3c6ab2e2008-09-04 11:19:41 +0200612
Willy Tarreaucff64112008-11-03 06:26:53 +0100613 if (si->ob->flags & BF_SHUTW) {
Willy Tarreau3c6ab2e2008-09-04 11:19:41 +0200614 fd_delete(si->fd);
Willy Tarreau74ab2ac2008-11-23 17:23:07 +0100615 si->state = SI_ST_DIS;
Willy Tarreau0a5d5dd2008-11-23 19:31:35 +0100616 return;
Willy Tarreau3c6ab2e2008-09-04 11:19:41 +0200617 }
618 EV_FD_CLR(si->fd, DIR_RD);
Willy Tarreau0a5d5dd2008-11-23 19:31:35 +0100619 return;
Willy Tarreau3c6ab2e2008-09-04 11:19:41 +0200620}
621
622/*
Willy Tarreau3a16b2c2008-08-28 08:54:27 +0200623 * Updates a connected stream_sock file descriptor status and timeouts
624 * according to the buffers' flags. It should only be called once after the
625 * buffer flags have settled down, and before they are cleared. It doesn't
626 * harm to call it as often as desired (it just slightly hurts performance).
627 */
Willy Tarreaub0253252008-11-30 21:37:12 +0100628void stream_sock_data_finish(struct stream_interface *si)
Willy Tarreau3a16b2c2008-08-28 08:54:27 +0200629{
Willy Tarreaub0253252008-11-30 21:37:12 +0100630 struct buffer *ib = si->ib;
631 struct buffer *ob = si->ob;
632 int fd = si->fd;
Willy Tarreau3a16b2c2008-08-28 08:54:27 +0200633
Willy Tarreaue5ed4062008-08-30 03:17:31 +0200634 DPRINTF(stderr,"[%u] %s: fd=%d owner=%p ib=%p, ob=%p, exp(r,w)=%u,%u ibf=%08x obf=%08x ibl=%d obl=%d si=%d\n",
Willy Tarreau3a16b2c2008-08-28 08:54:27 +0200635 now_ms, __FUNCTION__,
636 fd, fdtab[fd].owner,
637 ib, ob,
638 ib->rex, ob->wex,
639 ib->flags, ob->flags,
Willy Tarreaub0253252008-11-30 21:37:12 +0100640 ib->l, ob->l, si->state);
Willy Tarreau3a16b2c2008-08-28 08:54:27 +0200641
642 /* Check if we need to close the read side */
643 if (!(ib->flags & BF_SHUTR)) {
Willy Tarreau2d212792008-08-27 21:41:35 +0200644 /* Read not closed, update FD status and timeout for reads */
Willy Tarreau3a16b2c2008-08-28 08:54:27 +0200645 if (ib->flags & (BF_FULL|BF_HIJACK)) {
Willy Tarreau2d212792008-08-27 21:41:35 +0200646 /* stop reading */
Willy Tarreaub0ef7352008-12-14 13:26:20 +0100647 if ((ib->flags & (BF_FULL|BF_HIJACK)) == BF_FULL)
648 si->flags |= SI_FL_WAIT_ROOM;
Willy Tarreau2d212792008-08-27 21:41:35 +0200649 EV_FD_COND_C(fd, DIR_RD);
650 ib->rex = TICK_ETERNITY;
651 }
652 else {
653 /* (re)start reading and update timeout. Note: we don't recompute the timeout
654 * everytime we get here, otherwise it would risk never to expire. We only
655 * update it if is was not yet set, or if we already got some read status.
656 */
Willy Tarreaub0ef7352008-12-14 13:26:20 +0100657 si->flags &= ~SI_FL_WAIT_ROOM;
Willy Tarreau2d212792008-08-27 21:41:35 +0200658 EV_FD_COND_S(fd, DIR_RD);
Willy Tarreau86491c32008-12-14 09:04:47 +0100659 if (!(ib->flags & BF_READ_NOEXP) &&
660 (!tick_isset(ib->rex) || ib->flags & BF_READ_ACTIVITY))
Willy Tarreau2d212792008-08-27 21:41:35 +0200661 ib->rex = tick_add_ifset(now_ms, ib->rto);
662 }
663 }
664
665 /* Check if we need to close the write side */
666 if (!(ob->flags & BF_SHUTW)) {
Willy Tarreau2d212792008-08-27 21:41:35 +0200667 /* Write not closed, update FD status and timeout for writes */
Willy Tarreaudcef33f2009-01-07 19:33:39 +0100668 if ((ob->send_max == 0 && ob->splice_len == 0) ||
Willy Tarreau3ffeba12008-12-14 14:42:35 +0100669 (ob->flags & BF_EMPTY) ||
Willy Tarreau3da77c52008-08-29 09:58:42 +0200670 (ob->flags & (BF_HIJACK|BF_WRITE_ENA)) == 0) {
Willy Tarreau2d212792008-08-27 21:41:35 +0200671 /* stop writing */
Willy Tarreaub0ef7352008-12-14 13:26:20 +0100672 if ((ob->flags & (BF_EMPTY|BF_HIJACK|BF_WRITE_ENA)) == (BF_EMPTY|BF_WRITE_ENA))
673 si->flags |= SI_FL_WAIT_DATA;
Willy Tarreau2d212792008-08-27 21:41:35 +0200674 EV_FD_COND_C(fd, DIR_WR);
675 ob->wex = TICK_ETERNITY;
676 }
677 else {
678 /* (re)start writing and update timeout. Note: we don't recompute the timeout
679 * everytime we get here, otherwise it would risk never to expire. We only
680 * update it if is was not yet set, or if we already got some write status.
681 */
Willy Tarreaub0ef7352008-12-14 13:26:20 +0100682 si->flags &= ~SI_FL_WAIT_DATA;
Willy Tarreau2d212792008-08-27 21:41:35 +0200683 EV_FD_COND_S(fd, DIR_WR);
Willy Tarreau3da77c52008-08-29 09:58:42 +0200684 if (!tick_isset(ob->wex) || ob->flags & BF_WRITE_ACTIVITY) {
Willy Tarreau2d212792008-08-27 21:41:35 +0200685 ob->wex = tick_add_ifset(now_ms, ob->wto);
Willy Tarreau21e1be82008-08-29 11:30:14 +0200686 if (tick_isset(ob->wex) && tick_isset(ib->rex)) {
Willy Tarreau2d212792008-08-27 21:41:35 +0200687 /* Note: depending on the protocol, we don't know if we're waiting
688 * for incoming data or not. So in order to prevent the socket from
689 * expiring read timeouts during writes, we refresh the read timeout,
690 * except if it was already infinite.
691 */
692 ib->rex = ob->wex;
693 }
694 }
695 }
696 }
Willy Tarreau2d212792008-08-27 21:41:35 +0200697}
698
Willy Tarreau3ffeba12008-12-14 14:42:35 +0100699/* This function is used for inter-stream-interface calls. It is called by the
700 * consumer to inform the producer side that it may be interested in checking
701 * for free space in the buffer. Note that it intentionally does not update
702 * timeouts, so that we can still check them later at wake-up.
703 */
704void stream_sock_chk_rcv(struct stream_interface *si)
705{
706 struct buffer *ib = si->ib;
707
708 DPRINTF(stderr,"[%u] %s: fd=%d owner=%p ib=%p, ob=%p, exp(r,w)=%u,%u ibf=%08x obf=%08x ibl=%d obl=%d si=%d\n",
709 now_ms, __FUNCTION__,
710 fd, fdtab[fd].owner,
711 ib, ob,
712 ib->rex, ob->wex,
713 ib->flags, ob->flags,
714 ib->l, ob->l, si->state);
715
716 if (unlikely(si->state != SI_ST_EST || (ib->flags & BF_SHUTR)))
717 return;
718
719 if (ib->flags & (BF_FULL|BF_HIJACK)) {
720 /* stop reading */
721 if ((ib->flags & (BF_FULL|BF_HIJACK)) == BF_FULL)
722 si->flags |= SI_FL_WAIT_ROOM;
723 EV_FD_COND_C(si->fd, DIR_RD);
724 }
725 else {
726 /* (re)start reading */
727 si->flags &= ~SI_FL_WAIT_ROOM;
728 EV_FD_COND_S(si->fd, DIR_RD);
729 }
730}
731
732
733/* This function is used for inter-stream-interface calls. It is called by the
734 * producer to inform the consumer side that it may be interested in checking
735 * for data in the buffer. Note that it intentionally does not update timeouts,
736 * so that we can still check them later at wake-up.
737 */
738void stream_sock_chk_snd(struct stream_interface *si)
739{
740 struct buffer *ob = si->ob;
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100741 int retval;
Willy Tarreau3ffeba12008-12-14 14:42:35 +0100742
743 DPRINTF(stderr,"[%u] %s: fd=%d owner=%p ib=%p, ob=%p, exp(r,w)=%u,%u ibf=%08x obf=%08x ibl=%d obl=%d si=%d\n",
744 now_ms, __FUNCTION__,
745 fd, fdtab[fd].owner,
746 ib, ob,
747 ib->rex, ob->wex,
748 ib->flags, ob->flags,
749 ib->l, ob->l, si->state);
750
751 if (unlikely(si->state != SI_ST_EST || (ob->flags & BF_SHUTW)))
752 return;
753
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100754 if (!(si->flags & SI_FL_WAIT_DATA) || /* not waiting for data */
755 (fdtab[si->fd].ev & FD_POLL_OUT) || /* we'll be called anyway */
756 !(ob->send_max || ob->splice_len) || /* called with nothing to send ! */
757 !(ob->flags & (BF_HIJACK|BF_WRITE_ENA))) /* we may not write */
758 return;
759
760 retval = stream_sock_write_loop(si, ob);
761 if (retval < 0) {
762 /* Write error on the file descriptor. We mark the FD as STERROR so
763 * that we don't use it anymore and we notify the task.
764 */
765 fdtab[si->fd].state = FD_STERROR;
766 fdtab[si->fd].ev &= ~FD_POLL_STICKY;
767 si->flags |= SI_FL_ERR;
768 goto out_wakeup;
769 }
770
771 if (retval > 0 || (ob->send_max == 0 && ob->splice_len == 0)) {
772 /* the connection is established but we can't write. Either the
773 * buffer is empty, or we just refrain from sending because the
774 * send_max limit was reached. Maybe we just wrote the last
775 * chunk and need to close.
776 */
777 if (((ob->flags & (BF_SHUTW|BF_EMPTY|BF_HIJACK|BF_WRITE_ENA|BF_SHUTR)) ==
778 (BF_EMPTY|BF_WRITE_ENA|BF_SHUTR)) &&
779 (si->state == SI_ST_EST)) {
780 stream_sock_shutw(si);
781 goto out_wakeup;
782 }
783
Willy Tarreau3ffeba12008-12-14 14:42:35 +0100784 if ((ob->flags & (BF_EMPTY|BF_HIJACK|BF_WRITE_ENA)) == (BF_EMPTY|BF_WRITE_ENA))
785 si->flags |= SI_FL_WAIT_DATA;
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100786 ob->wex = TICK_ETERNITY;
Willy Tarreau3ffeba12008-12-14 14:42:35 +0100787 }
788 else {
789 /* (re)start writing. */
790 si->flags &= ~SI_FL_WAIT_DATA;
791 EV_FD_COND_S(si->fd, DIR_WR);
792 }
Willy Tarreaua456f2a2009-01-18 17:38:44 +0100793
794 /* in case of special condition (error, shutdown, end of write...), we
795 * have to notify the task.
796 */
797 if (likely((ob->flags & (BF_WRITE_NULL|BF_WRITE_ERROR|BF_SHUTW)) ||
798 (!ob->to_forward && !ob->send_max && !ob->splice_len) ||
799 si->state != SI_ST_EST)) {
800 out_wakeup:
801 task_wakeup(si->owner, TASK_WOKEN_IO);
802 }
Willy Tarreau3ffeba12008-12-14 14:42:35 +0100803}
804
Willy Tarreaubaaee002006-06-26 02:48:02 +0200805
806/*
807 * Local variables:
808 * c-indent-level: 8
809 * c-basic-offset: 8
810 * End:
811 */