blob: edfb7583b2179baf97fc1223818834d777276e83 [file] [log] [blame]
Willy Tarreaufa7e1022008-10-19 07:30:41 +02001/*
2 include/types/stream_interface.h
3 This file describes the stream_interface struct and associated constants.
4
5 Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation, version 2.1
10 exclusively.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22#ifndef _TYPES_STREAM_INTERFACE_H
23#define _TYPES_STREAM_INTERFACE_H
24
25#include <stdlib.h>
26
27#include <common/config.h>
28
29/* A stream interface must have its own errors independantly of the buffer's,
30 * so that applications can rely on what the buffer reports while the stream
31 * interface is performing some retries (eg: connection error).
32 */
33enum {
34 SI_ST_INI = 0, /* interface not initialized yet and might not exist */
35 SI_ST_QUE, /* interface waiting in queue */
36 SI_ST_TAR, /* interface in turn-around state after failed connect attempt */
37 SI_ST_ASS, /* server just assigned to this interface */
38 SI_ST_CON, /* initiated connection request (resource exists) */
39 SI_ST_EST, /* connection established (resource exists) */
40 SI_ST_CLO, /* stream interface closed, might not existing anymore */
41};
42
43/* error types reported on the streams interface for more accurate reporting */
44enum {
45 SI_ET_NONE = 0, /* no error yet, leave it to zero */
46 SI_ET_QUEUE_TO, /* queue timeout */
47 SI_ET_QUEUE_ERR, /* queue error (eg: full) */
48 SI_ET_QUEUE_ABRT, /* aborted in queue by external cause */
49 SI_ET_CONN_TO, /* connection timeout */
50 SI_ET_CONN_ERR, /* connection error (eg: no server available) */
51 SI_ET_CONN_ABRT, /* connection aborted by external cause (eg: abort) */
52 SI_ET_CONN_OTHER, /* connection aborted for other reason (eg: 500) */
53 SI_ET_DATA_TO, /* timeout during data phase */
54 SI_ET_DATA_ERR, /* error during data phase */
55 SI_ET_DATA_ABRT, /* data phase aborted by external cause */
56};
57
58struct stream_interface {
59 unsigned int state; /* SI_ST* */
60 int err_type; /* first error detected, one of SI_ET_* */
61 void *err_loc; /* commonly the server, NULL when SI_ET_NONE */
62 int fd; /* file descriptor for a stream driver when known */
63};
64
65
66#endif /* _TYPES_STREAM_INTERFACE_H */
67
68/*
69 * Local variables:
70 * c-indent-level: 8
71 * c-basic-offset: 8
72 * End:
73 */