blob: ae8872bee558ffa76d0c7703b8f4b1ca30c02309 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
Willy Tarreaue3ba5f02006-06-29 18:54:54 +02002 include/types/fd.h
Willy Tarreaubaaee002006-06-26 02:48:02 +02003 File descriptors states.
4
5 Copyright (C) 2000-2006 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_FD_H
23#define _TYPES_FD_H
24
25#include <sys/time.h>
26#include <sys/types.h>
27#include <unistd.h>
28
Willy Tarreau2dd0d472006-06-29 17:53:05 +020029#include <common/config.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020030#include <types/task.h>
Willy Tarreau54469402006-07-29 16:59:06 +020031#include <types/buffers.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020032
33/* different possible states for the fd */
34#define FD_STCLOSE 0
35#define FD_STLISTEN 1
36#define FD_STCONN 2
37#define FD_STREADY 3
38#define FD_STERROR 4
39
Willy Tarreau54469402006-07-29 16:59:06 +020040enum {
41 DIR_RD=0,
42 DIR_WR=1,
43 DIR_SIZE
44};
Willy Tarreaubaaee002006-06-26 02:48:02 +020045
46/* info about one given fd */
47struct fdtab {
Willy Tarreau54469402006-07-29 16:59:06 +020048 struct {
49 int (*f)(int fd); /* read/write function */
50 struct buffer *b; /* read/write buffer */
51 } cb[DIR_SIZE];
52 struct task *owner; /* the session (or proxy) associated with this fd */
53 int state; /* the state of this fd */
Willy Tarreaubaaee002006-06-26 02:48:02 +020054};
55
56extern struct fdtab *fdtab; /* array of all the file descriptors */
57extern int maxfd; /* # of the highest fd + 1 */
58extern int totalconn; /* total # of terminated sessions */
59extern int actconn; /* # of active sessions */
60
61#endif /* _TYPES_FD_H */
62
63/*
64 * Local variables:
65 * c-indent-level: 8
66 * c-basic-offset: 8
67 * End:
68 */