Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | include/types/polling.h |
| 3 | File descriptors and polling definitions. |
| 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_POLLING_H |
| 23 | #define _TYPES_POLLING_H |
| 24 | |
| 25 | /* for fd_set */ |
| 26 | #include <sys/time.h> |
| 27 | #include <sys/types.h> |
| 28 | #include <unistd.h> |
| 29 | |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 30 | #include <common/config.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 31 | |
| 32 | /* for POLL_* */ |
| 33 | #if defined(ENABLE_POLL) |
| 34 | #include <sys/poll.h> |
| 35 | #endif |
| 36 | |
| 37 | /* for EPOLL_* */ |
| 38 | #if defined(ENABLE_EPOLL) |
| 39 | #if !defined(USE_MY_EPOLL) |
| 40 | #include <sys/epoll.h> |
| 41 | #else |
Willy Tarreau | 2dd0d47 | 2006-06-29 17:53:05 +0200 | [diff] [blame] | 42 | #include <common/epoll.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 43 | #endif |
| 44 | #endif |
| 45 | |
| 46 | /* possible actions for the *poll() loops */ |
| 47 | #define POLL_LOOP_ACTION_INIT 0 |
| 48 | #define POLL_LOOP_ACTION_RUN 1 |
| 49 | #define POLL_LOOP_ACTION_CLEAN 2 |
| 50 | |
| 51 | /* poll mechanisms available */ |
| 52 | #define POLL_USE_SELECT (1<<0) |
| 53 | #define POLL_USE_POLL (1<<1) |
| 54 | #define POLL_USE_EPOLL (1<<2) |
| 55 | |
| 56 | /* result of an I/O event */ |
| 57 | #define RES_SILENT 0 /* didn't happen */ |
| 58 | #define RES_DATA 1 /* data were sent or received */ |
| 59 | #define RES_NULL 2 /* result is 0 (read == 0), or connect without need for writing */ |
| 60 | #define RES_ERROR 3 /* result -1 or error on the socket (eg: connect()) */ |
| 61 | |
| 62 | /* fd states */ |
| 63 | extern fd_set *StaticReadEvent, *StaticWriteEvent; |
| 64 | extern int cfg_polling_mechanism; /* POLL_USE_{SELECT|POLL|EPOLL} */ |
| 65 | |
| 66 | |
| 67 | #endif /* _TYPES_POLLING_H */ |
| 68 | |
| 69 | /* |
| 70 | * Local variables: |
| 71 | * c-indent-level: 8 |
| 72 | * c-basic-offset: 8 |
| 73 | * End: |
| 74 | */ |