BUG/MEDIUM: lua: the Lua process is not waked up after sending data on requests side

If we are writing in the request buffer, we are not waked up
when the data are forwarded because it is useles. The request
analyzers are waked up only when data is incoming. So, if the
request buffer is full, we set the WAKE_ON_WRITE flag.
This commit is contained in:
Thierry FOURNIER 2015-03-06 00:35:53 +01:00 committed by Willy Tarreau
parent ef6a2115fd
commit 53e08ecc41
3 changed files with 11 additions and 1 deletions

View File

@ -17,6 +17,9 @@
#define HLUA_SET_WAKERESWR(__hlua) do {(__hlua)->flags |= HLUA_WAKERESWR;} while(0)
#define HLUA_CLR_WAKERESWR(__hlua) do {(__hlua)->flags &= ~HLUA_WAKERESWR;} while(0)
#define HLUA_IS_WAKERESWR(__hlua) ((__hlua)->flags & HLUA_WAKERESWR)
#define HLUA_SET_WAKEREQWR(__hlua) do {(__hlua)->flags |= HLUA_WAKEREQWR;} while(0)
#define HLUA_CLR_WAKEREQWR(__hlua) do {(__hlua)->flags &= ~HLUA_WAKEREQWR;} while(0)
#define HLUA_IS_WAKEREQWR(__hlua) ((__hlua)->flags & HLUA_WAKEREQWR)
#define HLUA_INIT(__hlua) do { (__hlua)->T = 0; } while(0)

View File

@ -19,6 +19,7 @@ struct session;
#define HLUA_RUN 0x00000001
#define HLUA_CTRLYIELD 0x00000002
#define HLUA_WAKERESWR 0x00000004
#define HLUA_WAKEREQWR 0x00000008
enum hlua_exec {
HLUA_E_OK = 0,

View File

@ -2238,7 +2238,9 @@ __LJMP static int _hlua_channel_send(lua_State *L)
*/
if (chn->chn == chn->s->rep)
HLUA_SET_WAKERESWR(hlua);
WILL_LJMP(hlua_yieldk(L, 0, 0, _hlua_channel_send, TICK_ETERNITY, 0));
else
HLUA_SET_WAKEREQWR(hlua);
WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_channel_send_yield, TICK_ETERNITY, 0));
}
return 1;
@ -2298,6 +2300,8 @@ __LJMP static int hlua_channel_forward_yield(lua_State *L)
*/
if (chn->chn == chn->s->rep)
HLUA_SET_WAKERESWR(hlua);
else
HLUA_SET_WAKEREQWR(hlua);
/* Otherwise, we can yield waiting for new data in the inpout side. */
WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_channel_forward_yield, TICK_ETERNITY, 0));
@ -3269,6 +3273,8 @@ static int hlua_request_act_wrapper(struct hlua_rule *rule, struct proxy *px,
if ((analyzer & (AN_REQ_INSPECT_FE|AN_REQ_HTTP_PROCESS_FE)))
s->rep->analysers |= analyzer;
}
if (HLUA_IS_WAKEREQWR(&s->hlua))
s->req->flags |= CF_WAKE_WRITE;
return 0;
/* finished with error. */