1 commit 7c3fd37724c58cf09359e0d381a9be305dd7869b
2 Author: Olivier Houchard <cognet@ci0.org>
3 Date: Mon Feb 25 16:18:16 2019 +0100
5 BUG/MAJOR: listener: Make sure the listener exist before using it.
7 In listener_accept(), make sure we have a listener before attempting to
9 An another thread may have closed the FD meanwhile, and set fdtab[fd].owner
11 As the listener is not free'd, it is ok to attempt to accept() a new
12 connection even if the listener was closed. At worst the fd has been
13 reassigned to another connection, and accept() will fail anyway.
15 Many thanks to Richard Russo for reporting the problem, and suggesting the
18 This should be backported to 1.9 and 1.8.
20 (cherry picked from commit d16a9dfed80e75d730754b717370515265698cdd)
21 Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
22 (cherry picked from commit a2511ed1fcdfa8047dbe2268fc0259f9b06cf891)
23 Signed-off-by: William Lallemand <wlallemand@haproxy.org>
25 diff --git a/src/listener.c b/src/listener.c
26 index a30efe03..5f6fafbc 100644
29 @@ -441,8 +441,8 @@ void delete_listener(struct listener *listener)
30 void listener_accept(int fd)
32 struct listener *l = fdtab[fd].owner;
33 - struct proxy *p = l->bind_conf->frontend;
34 - int max_accept = l->maxaccept ? l->maxaccept : 1;
40 @@ -450,6 +450,10 @@ void listener_accept(int fd)
41 static int accept4_broken;
46 + p = l->bind_conf->frontend;
47 + max_accept = l->maxaccept ? l->maxaccept : 1;
48 if (HA_SPIN_TRYLOCK(LISTENER_LOCK, &l->lock))