From: Thierry FOURNIER Date: Thu, 5 Mar 2015 23:35:53 +0000 (+0100) Subject: BUG/MEDIUM: lua: the Lua process is not waked up after sending data on requests side X-Git-Tag: v1.6-dev1~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=53e08ecc41037a4e6d831e848ce809f625aefb7f;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/proto/hlua.h b/include/proto/hlua.h index c9c4ddeaa4..4215373efc 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 5a3dddbe7b..a385c02bfc 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 0e1df42283..7f937f72ec 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. */