packages/net/haproxy/patches/0002-BUG-MINOR-epoll-correctly-disable-FD-polling-i-1.4.22.diff
heil 240ad98e89 package: haproxy
- add missing patches
 - add patch number to version



git-svn-id: svn://svn.openwrt.org/openwrt/packages@35091 3c298f89-4303-0410-b956-a3cf2f4a3e73
2013-01-10 23:47:03 +00:00

54 lines
1.7 KiB
Diff

From 72ce4c8f4e0531c50b3a0914d77858440d16d914 Mon Sep 17 00:00:00 2001
From: Willy Tarreau <w@1wt.eu>
Date: Thu, 4 Oct 2012 21:54:41 +0200
Subject: BUG/MINOR: epoll: correctly disable FD polling in fd_rem()
When calling fd_rem(), the polling was not correctly disabled because the
->prev state was set to zero instead of the previous value. fd_rem() is
very rarely used, only just before closing a socket.
The effect is that upon an error reported at the connection level, if the
task assigned to the connection was too slow to be woken up because of too
many other tasks in the run queue, the FD was still not disabled and caused
the connection handler to be called again with the same event until the task
was finally executed to close the fd.
This issue only affects the epoll poller, not the sepoll variant nor any of
the other ones.
It was already present in 1.4 and even 1.3 with the same almost unnoticeable
effects. The bug can in fact only be discovered during development where it
emphasizes other bugs.
It should be backported anyway.
(cherry picked from commit f8cfa447c676849e1d1b007353d4ea2f7231e4a0)
---
src/ev_epoll.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/ev_epoll.c b/src/ev_epoll.c
index b976868..0b22da6 100644
--- a/src/ev_epoll.c
+++ b/src/ev_epoll.c
@@ -194,11 +194,15 @@ REGPRM2 static int __fd_clr(const int fd, int dir)
REGPRM1 static void __fd_rem(int fd)
{
uint32_t ofs = FD2OFS(fd);
+ uint32_t old_evt;
- if (unlikely(!((fd_evts[ofs] >> FD2BIT(fd)) & 3)))
+ old_evt = fd_evts[ofs] >> FD2BIT(fd);
+ old_evt &= 3;
+
+ if (unlikely(!old_evt))
return;
- alloc_chg_list(fd, 0);
+ alloc_chg_list(fd, old_evt);
fd_evts[ofs] &= ~FD2MSK(fd);
return;
}
--
1.7.1