mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-25 22:22:11 +00:00
1c2ad21e0f
* made epoll() support a compile-time option : ENABLE_EPOLL * provided a very little libc replacement for a possibly missing epoll() implementation which can be enabled by -DUSE_MY_EPOLL * implemented the poll() poller, which can be enabled with -DENABLE_POLL. The equivalent runtime argument becomes '-P'. A few tests show that it performs like select() with many fds, but slightly slower (certainly because of the higher amount of memory involved). * separated the 3 polling methods and the tasks scheduler into 4 distinct functions which makes the code a lot more modular. * moved some event tables to private static declarations inside the poller functions. * the poller functions can now initialize themselves, run, and cleanup. * changed the runtime argument to enable epoll() to '-E'. * removed buggy epoll_ctl() code in the client_retnclose() function. This function was never meant to remove anything. * fixed a typo which caused glibc to yell about a double free on exit. * removed error checking after epoll_ctl(DEL) because we can never know if the fd is still active or already closed. * added a few entries in the makefile
65 lines
1.7 KiB
C
65 lines
1.7 KiB
C
/*
|
|
* Those constants were found both in glibc and in the Linux kernel.
|
|
* They are provided here because the epoll() syscall is featured in
|
|
* some kernels but in not often included in the glibc, so it needs
|
|
* just a basic definition.
|
|
*/
|
|
|
|
#include <linux/unistd.h>
|
|
|
|
/* epoll_ctl() commands */
|
|
#define EPOLL_CTL_ADD 1
|
|
#define EPOLL_CTL_DEL 2
|
|
#define EPOLL_CTL_MOD 3
|
|
|
|
/* events types (bit fields) */
|
|
#define EPOLLIN 1
|
|
#define EPOLLPRI 2
|
|
#define EPOLLOUT 4
|
|
#define EPOLLERR 8
|
|
#define EPOLLHUP 16
|
|
#define EPOLLONESHOT (1 << 30)
|
|
#define EPOLLET (1 << 31)
|
|
|
|
struct epoll_event {
|
|
uint32_t events;
|
|
struct {
|
|
void *ptr;
|
|
int fd;
|
|
uint32_t u32;
|
|
uint64_t u64;
|
|
} data;
|
|
};
|
|
|
|
|
|
#if defined(__powerpc__) || defined(__powerpc64__)
|
|
#define __NR_epoll_create 236
|
|
#define __NR_epoll_ctl 237
|
|
#define __NR_epoll_wait 238
|
|
#elif defined(__sparc__) || defined(__sparc64__)
|
|
#define __NR_epoll_create 193
|
|
#define __NR_epoll_ctl 194
|
|
#define __NR_epoll_wait 195
|
|
#elif defined(__x86_64__)
|
|
#define __NR_epoll_create 213
|
|
#define __NR_epoll_ctl 214
|
|
#define __NR_epoll_wait 215
|
|
#elif defined(__alpha__)
|
|
#define __NR_sys_epoll_create 407
|
|
#define __NR_sys_epoll_ctl 408
|
|
#define __NR_sys_epoll_wait 409
|
|
#elif defined (__i386__)
|
|
#define __NR_epoll_create 254
|
|
#define __NR_epoll_ctl 255
|
|
#define __NR_epoll_wait 256
|
|
#else
|
|
#warning unsupported architecture, guessing __NR_epoll_create=254 like x86...
|
|
#define __NR_epoll_create 254
|
|
#define __NR_epoll_ctl 255
|
|
#define __NR_epoll_wait 256
|
|
#endif
|
|
|
|
_syscall1 (int, epoll_create, int, size);
|
|
_syscall4 (int, epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, event);
|
|
_syscall4 (int, epoll_wait, int, epfd, struct epoll_event *, events, int, maxevents, int, timeout);
|