From 53e08ecc41037a4e6d831e848ce809f625aefb7f Mon Sep 17 00:00:00 2001 From: Thierry FOURNIER Date: Fri, 6 Mar 2015 00:35:53 +0100 Subject: [PATCH] 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. --- include/proto/hlua.h | 3 +++ include/types/hlua.h | 1 + src/hlua.c | 8 +++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/proto/hlua.h b/include/proto/hlua.h index c9c4ddeaa..4215373ef 100644 --- a/include/proto/hlua.h +++ b/include/proto/hlua.h @@ -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) diff --git a/include/types/hlua.h b/include/types/hlua.h index 5a3dddbe7..a385c02bf 100644 --- a/include/types/hlua.h +++ b/include/types/hlua.h @@ -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, diff --git a/src/hlua.c b/src/hlua.c index 0e1df4228..7f937f72e 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -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. */