blob: cc33b815d884ae7fda7c0f0f74f340015ec51cbb [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
13#include <errno.h>
14#include <fcntl.h>
15#include <stdio.h>
16#include <stdlib.h>
17
18#include <sys/socket.h>
19#include <sys/stat.h>
20#include <sys/types.h>
21
Willy Tarreau2dd0d472006-06-29 17:53:05 +020022#include <common/compat.h>
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020023#include <common/config.h>
Willy Tarreaud6f087e2008-01-18 17:20:13 +010024#include <common/debug.h>
Willy Tarreau83749182007-04-15 20:56:27 +020025#include <common/standard.h>
Willy Tarreau0c303ee2008-07-07 00:09:58 +020026#include <common/ticks.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020027#include <common/time.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020028
Willy Tarreaubaaee002006-06-26 02:48:02 +020029#include <proto/client.h>
30#include <proto/fd.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020031#include <proto/stream_sock.h>
32#include <proto/task.h>
33
34
35/*
Willy Tarreaud7971282006-07-29 18:36:34 +020036 * this function is called on a read event from a stream socket.
Willy Tarreau83749182007-04-15 20:56:27 +020037 * It returns 0 if we have a high confidence that we will not be
38 * able to read more data without polling first. Returns non-zero
39 * otherwise.
Willy Tarreaubaaee002006-06-26 02:48:02 +020040 */
Willy Tarreaud7971282006-07-29 18:36:34 +020041int stream_sock_read(int fd) {
Willy Tarreau0c303ee2008-07-07 00:09:58 +020042 __label__ out_wakeup, out_shutdown_r, out_error;
Willy Tarreau54469402006-07-29 16:59:06 +020043 struct buffer *b = fdtab[fd].cb[DIR_RD].b;
Willy Tarreau8a7af602008-05-03 23:07:14 +020044 int ret, max, retval, cur_read;
Willy Tarreaub8949f12007-03-23 22:39:59 +010045 int read_poll = MAX_READ_POLL_LOOPS;
Willy Tarreaubaaee002006-06-26 02:48:02 +020046
47#ifdef DEBUG_FULL
Willy Tarreaud6f087e2008-01-18 17:20:13 +010048 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 +020049#endif
50
Willy Tarreau83749182007-04-15 20:56:27 +020051 retval = 1;
52
Willy Tarreaud6f087e2008-01-18 17:20:13 +010053 /* stop immediately on errors */
54 if (fdtab[fd].state == FD_STERROR || (fdtab[fd].ev & FD_POLL_ERR))
Willy Tarreau6996e152007-04-30 14:37:43 +020055 goto out_error;
Willy Tarreaud6f087e2008-01-18 17:20:13 +010056
57 /* stop here if we reached the end of data */
58 if ((fdtab[fd].ev & (FD_POLL_IN|FD_POLL_HUP)) == FD_POLL_HUP)
59 goto out_shutdown_r;
Willy Tarreau83749182007-04-15 20:56:27 +020060
Willy Tarreau8a7af602008-05-03 23:07:14 +020061 cur_read = 0;
Willy Tarreau6996e152007-04-30 14:37:43 +020062 while (1) {
63 /*
64 * 1. compute the maximum block size we can read at once.
65 */
Willy Tarreau83749182007-04-15 20:56:27 +020066 if (b->l == 0) { /* let's realign the buffer to optimize I/O */
67 b->r = b->w = b->lr = b->data;
68 max = b->rlim - b->data;
69 }
70 else if (b->r > b->w) {
71 max = b->rlim - b->r;
72 }
73 else {
74 max = b->w - b->r;
75 /* FIXME: theorically, if w>0, we shouldn't have rlim < data+size anymore
76 * since it means that the rewrite protection has been removed. This
77 * implies that the if statement can be removed.
78 */
79 if (max > b->rlim - b->data)
Willy Tarreaubaaee002006-06-26 02:48:02 +020080 max = b->rlim - b->data;
Willy Tarreau83749182007-04-15 20:56:27 +020081 }
Willy Tarreaubaaee002006-06-26 02:48:02 +020082
Willy Tarreau6996e152007-04-30 14:37:43 +020083 if (unlikely(max == 0)) {
84 /* Not anymore room to store data. This should theorically
85 * never happen, but better safe than sorry !
86 */
Willy Tarreaue393fe22008-08-16 22:18:07 +020087 b->flags |= BF_FULL;
Willy Tarreau83749182007-04-15 20:56:27 +020088 EV_FD_CLR(fd, DIR_RD);
Willy Tarreau0c303ee2008-07-07 00:09:58 +020089 b->rex = TICK_ETERNITY;
90 goto out_wakeup;
Willy Tarreau83749182007-04-15 20:56:27 +020091 }
Willy Tarreaubaaee002006-06-26 02:48:02 +020092
Willy Tarreau6996e152007-04-30 14:37:43 +020093 /*
94 * 2. read the largest possible block
95 */
Willy Tarreaubaaee002006-06-26 02:48:02 +020096#ifndef MSG_NOSIGNAL
Willy Tarreau83749182007-04-15 20:56:27 +020097 {
98 int skerr;
99 socklen_t lskerr = sizeof(skerr);
100
101 ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &skerr, &lskerr);
102 if (ret == -1 || skerr)
103 ret = -1;
104 else
105 ret = recv(fd, b->r, max, 0);
106 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200107#else
Willy Tarreau83749182007-04-15 20:56:27 +0200108 ret = recv(fd, b->r, max, MSG_NOSIGNAL);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200109#endif
Willy Tarreau83749182007-04-15 20:56:27 +0200110 if (ret > 0) {
111 b->r += ret;
112 b->l += ret;
Willy Tarreau8a7af602008-05-03 23:07:14 +0200113 cur_read += ret;
Willy Tarreau83749182007-04-15 20:56:27 +0200114 b->flags |= BF_PARTIAL_READ;
Willy Tarreaue393fe22008-08-16 22:18:07 +0200115 b->flags &= ~BF_EMPTY;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200116
Willy Tarreau83749182007-04-15 20:56:27 +0200117 if (b->r == b->data + BUFSIZE) {
118 b->r = b->data; /* wrap around the buffer */
119 }
Willy Tarreau9641e8f2007-03-23 23:02:09 +0100120
Willy Tarreau83749182007-04-15 20:56:27 +0200121 b->total += ret;
Willy Tarreau9641e8f2007-03-23 23:02:09 +0100122
Willy Tarreaue393fe22008-08-16 22:18:07 +0200123 if (b->l >= b->rlim - b->data) {
Willy Tarreau6996e152007-04-30 14:37:43 +0200124 /* The buffer is now full, there's no point in going through
125 * the loop again.
126 */
Willy Tarreau8a7af602008-05-03 23:07:14 +0200127 if (!(b->flags & BF_STREAMER_FAST) && (cur_read == b->l)) {
128 b->xfer_small = 0;
129 b->xfer_large++;
130 if (b->xfer_large >= 3) {
131 /* we call this buffer a fast streamer if it manages
132 * to be filled in one call 3 consecutive times.
133 */
134 b->flags |= (BF_STREAMER | BF_STREAMER_FAST);
135 //fputc('+', stderr);
136 }
137 }
138 else if ((b->flags & (BF_STREAMER | BF_STREAMER_FAST)) &&
139 (cur_read <= BUFSIZE / 2)) {
140 b->xfer_large = 0;
141 b->xfer_small++;
142 if (b->xfer_small >= 2) {
143 /* if the buffer has been at least half full twice,
144 * we receive faster than we send, so at least it
145 * is not a "fast streamer".
146 */
147 b->flags &= ~BF_STREAMER_FAST;
148 //fputc('-', stderr);
149 }
150 }
151 else {
152 b->xfer_small = 0;
153 b->xfer_large = 0;
154 }
155
Willy Tarreaue393fe22008-08-16 22:18:07 +0200156 b->flags |= BF_FULL;
Willy Tarreau6996e152007-04-30 14:37:43 +0200157 EV_FD_CLR(fd, DIR_RD);
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200158 b->rex = TICK_ETERNITY;
159 goto out_wakeup;
Willy Tarreau6996e152007-04-30 14:37:43 +0200160 }
161
Willy Tarreauab3e1d32007-06-03 14:10:36 +0200162 /* if too many bytes were missing from last read, it means that
163 * it's pointless trying to read again because the system does
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100164 * not have them in buffers. BTW, if FD_POLL_HUP was present,
165 * it means that we have reached the end and that the connection
166 * is closed.
Willy Tarreauab3e1d32007-06-03 14:10:36 +0200167 */
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100168 if (ret < max) {
Willy Tarreau8a7af602008-05-03 23:07:14 +0200169 if ((b->flags & (BF_STREAMER | BF_STREAMER_FAST)) &&
170 (cur_read <= BUFSIZE / 2)) {
171 b->xfer_large = 0;
172 b->xfer_small++;
173 if (b->xfer_small >= 3) {
174 /* we have read less than half of the buffer in
175 * one pass, and this happened at least 3 times.
176 * This is definitely not a streamer.
177 */
178 b->flags &= ~(BF_STREAMER | BF_STREAMER_FAST);
179 //fputc('!', stderr);
180 }
181 }
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100182 if (fdtab[fd].ev & FD_POLL_HUP)
183 goto out_shutdown_r;
Willy Tarreauab3e1d32007-06-03 14:10:36 +0200184 break;
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100185 }
Willy Tarreauab3e1d32007-06-03 14:10:36 +0200186
187 /* generally if we read something smaller than 1 or 2 MSS,
Willy Tarreau83749182007-04-15 20:56:27 +0200188 * it means that it's not worth trying to read again. It may
189 * also happen on headers, but the application then can stop
190 * reading before we start polling.
191 */
192 if (ret < MIN_RET_FOR_READ_LOOP)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200193 break;
Willy Tarreau83749182007-04-15 20:56:27 +0200194
Willy Tarreau6996e152007-04-30 14:37:43 +0200195 if (--read_poll <= 0)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200196 break;
Willy Tarreau83749182007-04-15 20:56:27 +0200197
Willy Tarreau83749182007-04-15 20:56:27 +0200198 }
199 else if (ret == 0) {
Willy Tarreau6996e152007-04-30 14:37:43 +0200200 /* connection closed */
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100201 goto out_shutdown_r;
Willy Tarreau83749182007-04-15 20:56:27 +0200202 }
Willy Tarreau9f195292007-04-15 21:26:58 +0200203 else if (errno == EAGAIN) {
204 /* Ignore EAGAIN but inform the poller that there is
Willy Tarreau6996e152007-04-30 14:37:43 +0200205 * nothing to read left. But we may have done some work
206 * justifying to notify the task.
Willy Tarreau9f195292007-04-15 21:26:58 +0200207 */
Willy Tarreau83749182007-04-15 20:56:27 +0200208 retval = 0;
209 break;
210 }
211 else {
Willy Tarreau6996e152007-04-30 14:37:43 +0200212 goto out_error;
Willy Tarreau83749182007-04-15 20:56:27 +0200213 }
Willy Tarreau6996e152007-04-30 14:37:43 +0200214 } /* while (1) */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200215
Willy Tarreau6996e152007-04-30 14:37:43 +0200216 /*
217 * The only way to get out of this loop is to have stopped reading
218 * without any error nor close, either by limiting the number of
219 * loops, or because of an EAGAIN. We only rearm the timer if we
220 * have at least read something.
221 */
222
Willy Tarreauadfb8562008-08-11 15:24:42 +0200223 if (tick_isset(b->rex) && b->flags & BF_PARTIAL_READ)
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200224 b->rex = tick_add_ifset(now_ms, b->rto);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200225
Willy Tarreaufa7e1022008-10-19 07:30:41 +0200226 if (!(b->flags & BF_READ_STATUS))
227 goto out_skip_wakeup;
Willy Tarreau6996e152007-04-30 14:37:43 +0200228 out_wakeup:
Willy Tarreaufa7e1022008-10-19 07:30:41 +0200229 task_wakeup(fdtab[fd].owner);
230
231 out_skip_wakeup:
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100232 fdtab[fd].ev &= ~FD_POLL_IN;
Willy Tarreau83749182007-04-15 20:56:27 +0200233 return retval;
Willy Tarreau6996e152007-04-30 14:37:43 +0200234
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100235 out_shutdown_r:
236 fdtab[fd].ev &= ~FD_POLL_HUP;
237 b->flags |= BF_READ_NULL;
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200238 b->rex = TICK_ETERNITY;
239 goto out_wakeup;
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100240
Willy Tarreau6996e152007-04-30 14:37:43 +0200241 out_error:
242 /* There was an error. we must wakeup the task. No need to clear
243 * the events, the task will do it.
244 */
245 fdtab[fd].state = FD_STERROR;
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100246 fdtab[fd].ev &= ~FD_POLL_STICKY;
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200247 b->rex = TICK_ETERNITY;
248 goto out_wakeup;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200249}
250
251
252/*
Willy Tarreauf8306d52006-07-29 19:01:31 +0200253 * this function is called on a write event from a stream socket.
Willy Tarreau83749182007-04-15 20:56:27 +0200254 * It returns 0 if we have a high confidence that we will not be
255 * able to write more data without polling first. Returns non-zero
256 * otherwise.
Willy Tarreaubaaee002006-06-26 02:48:02 +0200257 */
Willy Tarreauf8306d52006-07-29 19:01:31 +0200258int stream_sock_write(int fd) {
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200259 __label__ out_wakeup, out_error;
Willy Tarreau54469402006-07-29 16:59:06 +0200260 struct buffer *b = fdtab[fd].cb[DIR_WR].b;
Willy Tarreau83749182007-04-15 20:56:27 +0200261 int ret, max, retval;
262 int write_poll = MAX_WRITE_POLL_LOOPS;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200263
264#ifdef DEBUG_FULL
Willy Tarreauf8306d52006-07-29 19:01:31 +0200265 fprintf(stderr,"stream_sock_write : fd=%d, owner=%p\n", fd, fdtab[fd].owner);
Willy Tarreaubaaee002006-06-26 02:48:02 +0200266#endif
267
Willy Tarreau83749182007-04-15 20:56:27 +0200268 retval = 1;
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100269 if (fdtab[fd].state == FD_STERROR || (fdtab[fd].ev & FD_POLL_ERR))
Willy Tarreau6996e152007-04-30 14:37:43 +0200270 goto out_error;
Willy Tarreau83749182007-04-15 20:56:27 +0200271
Willy Tarreau6996e152007-04-30 14:37:43 +0200272 while (1) {
Willy Tarreau83749182007-04-15 20:56:27 +0200273 if (b->l == 0) { /* let's realign the buffer to optimize I/O */
274 b->r = b->w = b->lr = b->data;
275 max = 0;
276 }
277 else if (b->r > b->w) {
278 max = b->r - b->w;
279 }
280 else {
281 max = b->data + BUFSIZE - b->w;
282 }
283
Willy Tarreaubaaee002006-06-26 02:48:02 +0200284 if (max == 0) {
Willy Tarreauf8306d52006-07-29 19:01:31 +0200285 /* may be we have received a connection acknowledgement in TCP mode without data */
Willy Tarreau6996e152007-04-30 14:37:43 +0200286 if (likely(fdtab[fd].state == FD_STCONN)) {
Willy Tarreau6996e152007-04-30 14:37:43 +0200287 /* We have no data to send to check the connection, and
288 * getsockopt() will not inform us whether the connection
289 * is still pending. So we'll reuse connect() to check the
290 * state of the socket. This has the advantage of givig us
291 * the following info :
292 * - error
293 * - connecting (EALREADY, EINPROGRESS)
294 * - connected (EISCONN, 0)
295 */
Willy Tarreaue94ebd02007-10-09 17:14:37 +0200296 if ((connect(fd, fdtab[fd].peeraddr, fdtab[fd].peerlen) == 0))
Willy Tarreau6996e152007-04-30 14:37:43 +0200297 errno = 0;
298
299 if (errno == EALREADY || errno == EINPROGRESS) {
300 retval = 0;
Willy Tarreaufa7e1022008-10-19 07:30:41 +0200301 goto out_may_wakeup;
Willy Tarreauf8306d52006-07-29 19:01:31 +0200302 }
Willy Tarreau6996e152007-04-30 14:37:43 +0200303
304 if (errno && errno != EISCONN)
305 goto out_error;
306
307 /* OK we just need to indicate that we got a connection
308 * and that we wrote nothing.
309 */
310 b->flags |= BF_WRITE_NULL;
311 fdtab[fd].state = FD_STREADY;
Willy Tarreauf8306d52006-07-29 19:01:31 +0200312 }
313
Willy Tarreau6996e152007-04-30 14:37:43 +0200314 /* Funny, we were called to write something but there wasn't
315 * anything. Theorically we cannot get there, but just in case,
316 * let's disable the write event and pretend we never came there.
317 */
Willy Tarreauf161a342007-04-08 16:59:42 +0200318 EV_FD_CLR(fd, DIR_WR);
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200319 b->wex = TICK_ETERNITY;
320 goto out_wakeup;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200321 }
322
323#ifndef MSG_NOSIGNAL
324 {
325 int skerr;
326 socklen_t lskerr = sizeof(skerr);
327
Willy Tarreauc6423482006-10-15 14:59:03 +0200328 ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &skerr, &lskerr);
329 if (ret == -1 || skerr)
Willy Tarreaubaaee002006-06-26 02:48:02 +0200330 ret = -1;
331 else
332 ret = send(fd, b->w, max, MSG_DONTWAIT);
333 }
334#else
335 ret = send(fd, b->w, max, MSG_DONTWAIT | MSG_NOSIGNAL);
336#endif
337
338 if (ret > 0) {
339 b->l -= ret;
340 b->w += ret;
341
Willy Tarreau0f9f5052006-07-29 17:39:25 +0200342 b->flags |= BF_PARTIAL_WRITE;
Willy Tarreaue393fe22008-08-16 22:18:07 +0200343
344 if (b->l < b->rlim - b->data)
345 b->flags &= ~BF_FULL;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200346
347 if (b->w == b->data + BUFSIZE) {
348 b->w = b->data; /* wrap around the buffer */
349 }
Willy Tarreau83749182007-04-15 20:56:27 +0200350
Willy Tarreau6996e152007-04-30 14:37:43 +0200351 if (!b->l) {
Willy Tarreaue393fe22008-08-16 22:18:07 +0200352 b->flags |= BF_EMPTY;
Willy Tarreau6996e152007-04-30 14:37:43 +0200353 EV_FD_CLR(fd, DIR_WR);
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200354 b->wex = TICK_ETERNITY;
355 goto out_wakeup;
Willy Tarreau6996e152007-04-30 14:37:43 +0200356 }
Willy Tarreau83749182007-04-15 20:56:27 +0200357
Willy Tarreauab3e1d32007-06-03 14:10:36 +0200358 /* if the system buffer is full, don't insist */
359 if (ret < max)
360 break;
361
Willy Tarreau6996e152007-04-30 14:37:43 +0200362 if (--write_poll <= 0)
363 break;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200364 }
Willy Tarreau6996e152007-04-30 14:37:43 +0200365 else if (ret == 0 || errno == EAGAIN) {
366 /* nothing written, just pretend we were never called
367 * and wait for the socket to be ready. But we may have
368 * done some work justifying to notify the task.
369 */
Willy Tarreau83749182007-04-15 20:56:27 +0200370 retval = 0;
371 break;
372 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200373 else {
Willy Tarreau6996e152007-04-30 14:37:43 +0200374 goto out_error;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200375 }
Willy Tarreau6996e152007-04-30 14:37:43 +0200376 } /* while (1) */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200377
Willy Tarreau6996e152007-04-30 14:37:43 +0200378 /*
379 * The only way to get out of this loop is to have stopped writing
380 * without any error, either by limiting the number of loops, or
381 * because of an EAGAIN. We only rearm the timer if we have at least
382 * written something.
383 */
384
Willy Tarreauadfb8562008-08-11 15:24:42 +0200385 if (tick_isset(b->wex) && b->flags & BF_PARTIAL_WRITE) {
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200386 b->wex = tick_add_ifset(now_ms, b->wto);
Willy Tarreauadfb8562008-08-11 15:24:42 +0200387 if (tick_isset(b->wex)) {
Willy Tarreau83749182007-04-15 20:56:27 +0200388 /* FIXME: to prevent the client from expiring read timeouts during writes,
389 * we refresh it. A solution would be to merge read+write timeouts into a
390 * unique one, although that needs some study particularly on full-duplex
391 * TCP connections. */
Willy Tarreauba392ce2008-08-16 21:13:23 +0200392 if (tick_isset(b->rex) && !(b->flags & BF_SHUTR))
Willy Tarreaufa645582007-06-03 15:59:52 +0200393 b->rex = b->wex;
Willy Tarreau83749182007-04-15 20:56:27 +0200394 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200395 }
Willy Tarreaubaaee002006-06-26 02:48:02 +0200396
Willy Tarreaufa7e1022008-10-19 07:30:41 +0200397 out_may_wakeup:
398 if (!(b->flags & BF_WRITE_STATUS))
399 goto out_skip_wakeup;
Willy Tarreau6996e152007-04-30 14:37:43 +0200400 out_wakeup:
Willy Tarreaufa7e1022008-10-19 07:30:41 +0200401 task_wakeup(fdtab[fd].owner);
402
403 out_skip_wakeup:
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100404 fdtab[fd].ev &= ~FD_POLL_OUT;
Willy Tarreau83749182007-04-15 20:56:27 +0200405 return retval;
Willy Tarreau6996e152007-04-30 14:37:43 +0200406
407 out_error:
408 /* There was an error. we must wakeup the task. No need to clear
409 * the events, the task will do it.
410 */
411 fdtab[fd].state = FD_STERROR;
Willy Tarreaud6f087e2008-01-18 17:20:13 +0100412 fdtab[fd].ev &= ~FD_POLL_STICKY;
Willy Tarreau0c303ee2008-07-07 00:09:58 +0200413 b->wex = TICK_ETERNITY;
414 goto out_wakeup;
Willy Tarreaubaaee002006-06-26 02:48:02 +0200415}
416
Willy Tarreaubaaee002006-06-26 02:48:02 +0200417
418
419/*
420 * Local variables:
421 * c-indent-level: 8
422 * c-basic-offset: 8
423 * End:
424 */