Merge pull request #3839 from thess/icecast-update
[feed/packages.git] / net / haproxy / patches / 0009-BUG-MINOR-Fix-the-sending-function-in-Lua-s-cosocket.patch
1 From 8d570235f18eb7a6c920d674d1a057f35c6740e8 Mon Sep 17 00:00:00 2001
2 From: Christopher Faulet <cfaulet@haproxy.com>
3 Date: Mon, 19 Dec 2016 09:29:06 +0100
4 Subject: [PATCH 09/19] BUG/MINOR: Fix the sending function in Lua's cosocket
5
6 This is a regression from the commit a73e59b6901a164d19b1145e8511602d9814f28f.
7
8 When data are sent from a cosocket, the action is done in the context of the
9 applet running a lua stack and not in the context of the applet owning the
10 cosocket. So we must take care, explicitly, that this last applet have a buffer
11 (the req buffer of the cosocket).
12
13 This patch must be backported in 1.7
14 (cherry picked from commit 33834b15dce4658ee98fa85668162d78abf32e18)
15 ---
16 src/hlua.c | 14 ++++++++------
17 1 file changed, 8 insertions(+), 6 deletions(-)
18
19 diff --git a/src/hlua.c b/src/hlua.c
20 index cee2c1b..e82656b 100644
21 --- a/src/hlua.c
22 +++ b/src/hlua.c
23 @@ -1884,14 +1884,19 @@ static int hlua_socket_write_yield(struct lua_State *L,int status, lua_KContext
24 * the request buffer if its not required.
25 */
26 if (socket->s->req.buf->size == 0) {
27 - si_applet_cant_put(&socket->s->si[0]);
28 - goto hlua_socket_write_yield_return;
29 + appctx = hlua->task->context;
30 + if (!channel_alloc_buffer(&socket->s->req, &appctx->buffer_wait))
31 + goto hlua_socket_write_yield_return;
32 }
33
34 /* Check for avalaible space. */
35 len = buffer_total_space(socket->s->req.buf);
36 - if (len <= 0)
37 + if (len <= 0) {
38 + appctx = objt_appctx(socket->s->si[0].end);
39 + if (!hlua_com_new(hlua, &appctx->ctx.hlua.wake_on_write))
40 + WILL_LJMP(luaL_error(L, "out of memory"));
41 goto hlua_socket_write_yield_return;
42 + }
43
44 /* send data */
45 if (len < send_len)
46 @@ -1929,9 +1934,6 @@ static int hlua_socket_write_yield(struct lua_State *L,int status, lua_KContext
47 return 1;
48
49 hlua_socket_write_yield_return:
50 - appctx = objt_appctx(socket->s->si[0].end);
51 - if (!hlua_com_new(hlua, &appctx->ctx.hlua.wake_on_write))
52 - WILL_LJMP(luaL_error(L, "out of memory"));
53 WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_socket_write_yield, TICK_ETERNITY, 0));
54 return 0;
55 }
56 --
57 2.10.2
58