From 85cb16d14c2f7c7ea84a9ee993466e5020d8bfb0 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Wed, 3 Jan 2007 12:54:05 +0100 Subject: [PATCH] Added ELINKS_EPOLL_SIZE to the setup.h. 128 is enough for most uses. --- src/main/main.c | 2 +- src/main/select.c | 9 +++------ src/setup.h | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/main.c b/src/main/main.c index 5e7fe579..a375db86 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -120,7 +120,7 @@ init(void) #endif #ifdef CONFIG_EPOLL - epoll_fd = epoll_create(1024); + epoll_fd = epoll_create(ELINKS_EPOLL_SIZE); if (epoll_fd == -1) { program.retval = RET_EPOLL; program.terminate = 1; diff --git a/src/main/select.c b/src/main/select.c index 1c154afe..fcfe976f 100644 --- a/src/main/select.c +++ b/src/main/select.c @@ -57,7 +57,7 @@ struct thread { static struct thread threads[FD_SETSIZE]; #ifdef CONFIG_EPOLL -static struct epoll_event events[FD_SETSIZE]; +static struct epoll_event events[ELINKS_EPOLL_SIZE]; #else static fd_set w_read; static fd_set w_write; @@ -66,9 +66,8 @@ static fd_set w_error; static fd_set x_read; static fd_set x_write; static fd_set x_error; - -#endif static int w_max; +#endif int get_file_handles_count(void) @@ -172,10 +171,8 @@ set_handlers(int fd, select_handler_T read_func, select_handler_T write_func, if (read_func || write_func || error_func) { if (epoll_ctl(epoll_fd, EPOLL_CTL_MOD, fd, &ev)) epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev); - if (fd > w_max) w_max = fd; } else { epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fd, &ev); - if (w_max == fd) w_max--; } } @@ -220,7 +217,7 @@ select_loop(void (*init)(void)) timeout = -1; } - n = epoll_wait(epoll_fd, events, w_max, timeout); + n = epoll_wait(epoll_fd, events, ELINKS_EPOLL_SIZE, timeout); if (n < 0) { /* The following calls (especially gettext) * might change errno. */ diff --git a/src/setup.h b/src/setup.h index 8b6e0c03..e80f2ab2 100644 --- a/src/setup.h +++ b/src/setup.h @@ -110,4 +110,5 @@ * to fit in the screen, with this much extra space. Try 4. */ #define TABLE_LINE_PADDING -1 +#define ELINKS_EPOLL_SIZE 128 #endif