]> git.kaiwu.me - haproxy.git/commit
BUG/MEDIUM: polling: fix possible CPU hogging of worker processes after receiving...
authorConrad Hoffmann <conrad@soundcloud.com>
Tue, 20 May 2014 12:28:24 +0000 (14:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 20 May 2014 12:57:36 +0000 (14:57 +0200)
commit041751c13a88ade79d45412db1c6bde6c0f2f901
tree4180b1c2b171ca3ca5281fc8c5f88c549de33139
parentaf5c3da89e408427b9dcfcfa47ae53eb9e797b1f
BUG/MEDIUM: polling: fix possible CPU hogging of worker processes after receiving SIGUSR1.

When run in daemon mode (i.e. with at least one forked process) and using
the epoll poller, sending USR1 (graceful shutdown) to the worker processes
can cause some workers to start running at 100% CPU. Precondition is having
an established HTTP keep-alive connection when the signal is received.

The cloned (during fork) listening sockets do not get closed in the parent
process, thus they do not get removed from the epoll set automatically
(see man 7 epoll). This can lead to the process receiving epoll events
that it doesn't feel responsible for, resulting in an endless loop around
epoll_wait() delivering these events.

The solution is to explicitly remove these file descriptors from the epoll
set. To not degrade performance, care was taken to only do this when
neccessary, i.e. when the file descriptor was cloned during fork.

Signed-off-by: Conrad Hoffmann <conrad@soundcloud.com>
[wt: a backport to 1.4 could be studied though chances to catch the bug are low]
include/proto/fd.h
include/types/fd.h
src/ev_epoll.c
src/fd.c