On Thu, Oct 11, 2018 at 11:06:38PM +0200, William Lallemand wrote:
> On Thu, Oct 11, 2018 at 09:31:48PM +0200, PiBa-NL wrote:
> > Hi Willy, William,
> > 
> 
> Hi Peter,
> 
> Regarding this part:
>  
> > -Connection and request counters to low when ran as regtest from 
> > varnishtest (bug?)
> > It turns out that starting haproxy from varnishtest, and using -W 
> > master-worker mode, actually creates 2 processes that are handling 
> > traffic. That explains that a large part of connections isn't seen by 
> > the other haproxy instance and stats showing to low amounts of 
> > connections. Bisecting it seems to fail on this commit: b3f2be3 , 
> > perhaps @William can you take a look at it? Not really sure when this 
> > occurs in a 'real' environment, it doesn't seem to happen when manually 
> > running haproxy -W, but still its strange that when varnisttest is 
> > calling haproxy this occurs.
> > 
> 
> There was an exception in the master's code regarding the inherited FDs (fd@),
> which is the case with varnishtest. There is a flag which was forbidding the
> master to close the FD in 1.8.
> 
> Now there is a polling loop in the master and I think there is a side effect
> where the FD is registered in the master polling loop.
> 
> It's just a guess, I'll look at it tomorrow.
> 
> Cheers,
> 

The attached patch should fix the issue.

-- 
William Lallemand
>From 3f2c30a0f15e30b7941245d3c5b20cbd5561489f Mon Sep 17 00:00:00 2001
From: William Lallemand <wlallem...@haproxy.com>
Date: Fri, 12 Oct 2018 10:39:54 +0200
Subject: [PATCH] BUG/MEDIUM: mworker: don't poll on LI_O_INHERITED listeners

The listeners with the LI_O_INHERITED flag were deleted but not unbound
which is a problem since we have a polling in the master.

This patch unbind every listeners which are not require for the master,
but does not close the FD of those that have a LI_O_INHERITED flag.
---
 src/haproxy.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/haproxy.c b/src/haproxy.c
index a7b07a267..82da86222 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -615,13 +615,17 @@ static void mworker_cleanlisteners()
 
 	for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
 		list_for_each_entry_safe(l, l_next, &curproxy->conf.listeners, by_fe) {
-			/* does not close if the FD is inherited with fd@
-			 * from the parent process */
-			if (!(l->options & (LI_O_INHERITED|LI_O_MWORKER)))
-				unbind_listener(l);
 			/* remove the listener, but not those we need in the master... */
-			if (!(l->options & LI_O_MWORKER))
+			if (!(l->options & LI_O_MWORKER)) {
+				/* unbind the listener but does not close if
+				   the FD is inherited with fd@ from the parent
+				   process */
+				if (l->options & LI_O_INHERITED)
+					unbind_listener_no_close(l);
+				else
+					unbind_listener(l);
 				delete_listener(l);
+			}
 		}
 	}
 }
-- 
2.16.4

Reply via email to