blob: 9b4c63279098375bd0d7882febc4621819df14c7 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 include/proto/fd.h
3 File descriptors states.
4
Willy Tarreau4f60f162007-04-08 16:39:58 +02005 Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu
Willy Tarreaubaaee002006-06-26 02:48:02 +02006
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 _PROTO_FD_H
23#define _PROTO_FD_H
24
25#include <sys/time.h>
26#include <sys/types.h>
27#include <unistd.h>
28
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020029#include <common/config.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020030#include <types/fd.h>
31
32/* Deletes an FD from the fdsets, and recomputes the maxfd limit.
33 * The file descriptor is also closed.
34 */
35void fd_delete(int fd);
36
Willy Tarreau4f60f162007-04-08 16:39:58 +020037/* registers all known pollers */
38void register_pollers();
39
40/* disable the specified poller */
41void disable_poller(const char *poller_name);
Willy Tarreaubaaee002006-06-26 02:48:02 +020042
Willy Tarreau2a429502006-10-15 14:52:29 +020043/*
Willy Tarreau4f60f162007-04-08 16:39:58 +020044 * Initialize the pollers till the best one is found.
45 * If none works, returns 0, otherwise 1.
Willy Tarreau2a429502006-10-15 14:52:29 +020046 */
Willy Tarreau4f60f162007-04-08 16:39:58 +020047int init_pollers();
Willy Tarreau2a429502006-10-15 14:52:29 +020048
Willy Tarreau4f60f162007-04-08 16:39:58 +020049/*
50 * Runs the polling loop
51 */
52void run_poller();
Willy Tarreau2a429502006-10-15 14:52:29 +020053
Willy Tarreauf161a342007-04-08 16:59:42 +020054#define EV_FD_SET(fd, ev) (cur_poller.set((fd), (ev)))
55#define EV_FD_CLR(fd, ev) (cur_poller.clr((fd), (ev)))
Willy Tarreau63455a92007-04-09 15:34:49 +020056#define EV_FD_ISSET(fd, ev) (cur_poller.is_set((fd), (ev)))
Willy Tarreauf161a342007-04-08 16:59:42 +020057#define EV_FD_COND_S(fd, ev) (cur_poller.cond_s((fd), (ev)))
58#define EV_FD_COND_C(fd, ev) (cur_poller.cond_c((fd), (ev)))
Willy Tarreau4f60f162007-04-08 16:39:58 +020059#define EV_FD_REM(fd) (cur_poller.rem(fd))
60#define EV_FD_CLO(fd) (cur_poller.clo(fd))
Willy Tarreau2a429502006-10-15 14:52:29 +020061
62
Willy Tarreaubaaee002006-06-26 02:48:02 +020063/* recomputes the maxfd limit from the fd */
64static inline void fd_insert(int fd)
65{
66 if (fd + 1 > maxfd)
67 maxfd = fd + 1;
68}
69
70
71#endif /* _PROTO_FD_H */
72
73/*
74 * Local variables:
75 * c-indent-level: 8
76 * c-basic-offset: 8
77 * End:
78 */