From: Thierry FOURNIER Date: Thu, 5 Mar 2015 16:06:12 +0000 (+0100) Subject: BUG/MINOR: lua: set buffer if it is nnot avalaible. X-Git-Tag: v1.6-dev1~61 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3e3a608f19c2b03d1dbca8e009e44ad24db7c2e4;p=thirdparty%2Fhaproxy.git BUG/MINOR: lua: set buffer if it is nnot avalaible. Check if the buffer is avalaible because HAProxy doesn't allocate the request buffer if its not required. Sometimes, the Lua need to write some data to the server before that the client send his data. --- diff --git a/src/hlua.c b/src/hlua.c index 073c4086a2..cc88bd1a59 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -2195,6 +2195,16 @@ __LJMP static int _hlua_channel_send(lua_State *L) return 1; } + /* Check if the buffer is avalaible because HAProxy doesn't allocate + * the request buffer if its not required. + */ + if (chn->chn->buf->size == 0) { + if (!session_alloc_recv_buffer(chn->s, &chn->chn->buf)) { + chn->chn->prod->flags |= SI_FL_WAIT_ROOM; + WILL_LJMP(hlua_yieldk(L, 0, 0, _hlua_channel_send, TICK_ETERNITY, 0)); + } + } + max = channel_recv_limit(chn->chn) - buffer_len(chn->chn->buf); if (max > len - l) max = len - l;