On Tue, Dec 17, 2013 at 02:05:13PM +0100, Willy Tarreau wrote:
> On Tue, Dec 17, 2013 at 10:44:12AM +0100, Guillaume Castagnino wrote:
> > Le mardi 17 décembre 2013 10:32:30 Sander Klein a écrit :
> > > Hi,
> > > 
> > > I've enabled http-keep-alive in my config and now haproxy continuously
> > > peaks at 100% CPU usage where without http-keep-alive it only uses
> > > 10-13% CPU.
> > > 
> > > Is this normal/expected behavior?
> > 
> > Hi,
> > 
> > Indeed, I can confirm this behaviour when enabling server-side 
> > keepalive.
> 
> So it looks like the simple idle connection manager I did yesterday
> is still not perfect :-/
> I tried to trigger this case but could not manage to make it fail,
> so I considered that was OK.

OK I could reproduce it. I only focused on closed connections yesterday,
and not the maitained ones :-(

Here's the fix. Thanks guys!
Willy

>From ea90063cbcc03506510522809d564112aa1a9ce9 Mon Sep 17 00:00:00 2001
From: Willy Tarreau <[email protected]>
Date: Tue, 17 Dec 2013 14:21:48 +0100
Subject: BUG/MEDIUM: stream-int: fix the keep-alive idle connection handler

Commit 2737562 (MEDIUM: stream-int: implement a very simplistic idle
connection manager) implemented an idle connection handler. In the
case where all data is drained from the server, it fails to disable
polling, resulting in a busy spinning loop.

Thanks to Sander Klein and Guillaume Castagnino for reporting this bug.

No backport is needed.
---
 src/stream_interface.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/stream_interface.c b/src/stream_interface.c
index 5c4633b..bf0a400 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -508,6 +508,8 @@ static void si_idle_conn_null_cb(struct connection *conn)
        /* disable draining if we were called and have no drain function */
        if (!conn->ctrl->drain)
                __conn_data_stop_recv(conn);
+       else if (!(conn->flags & CO_FL_SOCK_RD_SH))
+               __conn_data_poll_recv(conn);
 }
 
 /* Callback to be used by connection I/O handlers when some activity is 
detected
-- 
1.7.1

Reply via email to