On Tue, 10 Mar 2015 01:05:50 +0100
Cyril Bonté <cyril.bo...@free.fr> wrote:

> Hi again,
> 
> Le 10/03/2015 00:40, Thierry FOURNIER a écrit :
> > On Mon, 09 Mar 2015 22:11:56 +0100
> > Cyril Bonté <cyril.bo...@free.fr> wrote:
> >> I've seen new commits that have been merged on the git repository.
> >> The bad news are that the previous test that I reported (sending a
> >> response larger than the buffer) doesn't work anymore :-/
> >> Resulting in :
> >>
> >> [ALERT] 067/220744 (27176) : Lua function 'hello_world': execution timeout.
> >
> >
> > Hi cyril,
> >
> > This is due to the implementation of the Lua execution timeout. This is
> > a system used to prevent loops in scripts. The Timeout is set by
> > default to 4s. You can see "tune.lua.session-timeout",
> > "tune.lua.task-timeout" and "tune.lua.forced-yield"
> >
> >     
> > http://cbonte.github.io/haproxy-dconv/snapshot/configuration-1.6.html#tune.lua.session-timeout
> 
> Of course, but it shouldn't take 4 seconds, the answer is immediate in 
> my test case.
> Actually, I could find that it was reproducible beginning with a 
> response greater or equal to 16392 bytes (I've not read the code yet).


Thank you Cyril, the bug is partially reproduced and fixed (the buffer
is not sent, but the error timeout is after 4 seconds as expected). I
attach the patch. I think that Willy must check this patch, because
it is possible than the comparison which I modify, did make sense.

Thierry


> haproxy.cfg:
> global
>     lua-load hello_world.lua
> 
> listen proxy
>     bind 127.0.0.1:10001
>     tcp-request content lua hello_world
> 
> 
> hello_world.lua:
> function hello_world(txn)
>     local res = txn:res_channel()
> 
>     s = ""
>     for i = 1,16392 do
>          s = s .. "x"
>     end
>     res:send(s)
> end
> 
> -- 
> Cyril Bonté
> 
>From f0185cae264f0309e386b500be115051a30e120b Mon Sep 17 00:00:00 2001
From: Thierry FOURNIER <tfourn...@exceliance.fr>
Date: Tue, 10 Mar 2015 01:55:01 +0100
Subject: [PATCH] BUG/MEDIUM: buffer: one byte miss in buffer free space check

Space is not avalaible only if the end of the data inserted
is strictly greater than the end of buffer. If these two value
are equal, the space is avamaible.
---
 src/buffer.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/buffer.c b/src/buffer.c
index e156991..3c7f6cc 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -75,7 +75,7 @@ int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int
 
 	delta = len - (end - pos);
 
-	if (bi_end(b) + delta >= b->data + b->size)
+	if (bi_end(b) + delta > b->data + b->size)
 		return 0;  /* no space left */
 
 	if (buffer_not_empty(b) &&
-- 
1.7.10.4

Reply via email to