CLEANUP: epoll: place the struct epoll_event in the stack
Historically we used to have a global epoll_event for various
manipulations involving epoll_ctl() and when threads were added,
this was turned to a thread_local, which is needlessly expensive
since it's just a temporary variable. Let's move it to a local
variable wherever it's called instead.
diff --git a/src/ev_epoll.c b/src/ev_epoll.c
index 1f8ef2b..bbba0ec 100644
--- a/src/ev_epoll.c
+++ b/src/ev_epoll.c
@@ -34,11 +34,6 @@
static THREAD_LOCAL struct epoll_event *epoll_events = NULL;
static int epoll_fd[MAX_THREADS]; // per-thread epoll_fd
-/* This structure may be used for any purpose. Warning! do not use it in
- * recursive functions !
- */
-static THREAD_LOCAL struct epoll_event ev;
-
#ifndef EPOLLRDHUP
/* EPOLLRDHUP was defined late in libc, and it appeared in kernel 2.6.17 */
#define EPOLLRDHUP 0x2000
@@ -54,6 +49,7 @@
{
if (unlikely(fdtab[fd].cloned)) {
unsigned long m = polled_mask[fd].poll_recv | polled_mask[fd].poll_send;
+ struct epoll_event ev;
int i;
for (i = global.nbthread - 1; i >= 0; i--)
@@ -65,6 +61,7 @@
static void _update_fd(int fd)
{
int en, opcode;
+ struct epoll_event ev;
en = fdtab[fd].state;
@@ -209,8 +206,10 @@
/* process polled events */
for (count = 0; count < status; count++) {
- unsigned int n;
- unsigned int e = epoll_events[count].events;
+ struct epoll_event ev;
+ unsigned int n, e;
+
+ e = epoll_events[count].events;
fd = epoll_events[count].data.fd;
if (!fdtab[fd].owner) {