mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-16 18:46:54 +00:00
BUG/MINOR: lua/htx: Respect the reserve when data are send from an HTX applet
In the function hlua_applet_htx_send_yield(), there already was a test to respect the reserve but the wrong function was used to get the available space for data in the HTX buffer. Instead of calling htx_free_space(), the function htx_free_data_space() must be used. But in fact, there is no reason to bother with that anymore because the function channel_htx_recv_max() has been added for this purpose. The result of this bug is that the call to htx_add_data() failed unexpectedly while the amount of written data was incremented, leading the applet to think all data was sent. To prevent any futher bugs, a test has been added to yield if we are not able to write data into the channel buffer. This patch must be backported to 1.9.
This commit is contained in:
parent
61ae5ca1f4
commit
4b0e9b2870
17
src/hlua.c
17
src/hlua.c
@ -4622,14 +4622,9 @@ __LJMP static int hlua_applet_htx_send_yield(lua_State *L, int status, lua_KCont
|
||||
int l = MAY_LJMP(luaL_checkinteger(L, 3));
|
||||
int max;
|
||||
|
||||
max = htx_free_space(htx);
|
||||
if (channel_recv_limit(res) < b_size(&res->buf)) {
|
||||
if (max < global.tune.maxrewrite) {
|
||||
si_rx_room_blk(si);
|
||||
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_htx_send_yield, TICK_ETERNITY, 0));
|
||||
}
|
||||
max -= global.tune.maxrewrite;
|
||||
}
|
||||
max = channel_htx_recv_max(res, htx);
|
||||
if (!max)
|
||||
goto snd_yield;
|
||||
|
||||
data = MAY_LJMP(luaL_checklstring(L, 2, &len));
|
||||
|
||||
@ -4638,8 +4633,9 @@ __LJMP static int hlua_applet_htx_send_yield(lua_State *L, int status, lua_KCont
|
||||
max = len - l;
|
||||
|
||||
/* Copy data. */
|
||||
htx_add_data(htx, ist2(data + l, max));
|
||||
res->total += l;
|
||||
if (!htx_add_data(htx, ist2(data + l, max)))
|
||||
goto snd_yield;
|
||||
res->total += max;
|
||||
res->flags |= CF_READ_PARTIAL;
|
||||
htx_to_buf(htx, &res->buf);
|
||||
|
||||
@ -4652,6 +4648,7 @@ __LJMP static int hlua_applet_htx_send_yield(lua_State *L, int status, lua_KCont
|
||||
* applet, and returns a yield.
|
||||
*/
|
||||
if (l < len) {
|
||||
snd_yield:
|
||||
si_rx_room_blk(si);
|
||||
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_htx_send_yield, TICK_ETERNITY, 0));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user