]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua: the Lua process is not waked up after sending data on requests side
authorThierry FOURNIER <tfournier@exceliance.fr>
Thu, 5 Mar 2015 23:35:53 +0000 (00:35 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Mar 2015 16:47:52 +0000 (17:47 +0100)
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
include/types/hlua.h
src/hlua.c

index c9c4ddeaa4d20f6b257d6e83256354f5e51dcf43..4215373efc50830ace088d9f0460dd6621deb7fe 100644 (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)
 
index 5a3dddbe7bba918b5b421fa8af9f1aff6ee83b8b..a385c02bfcf495e799362421ced4b88560a169f5 100644 (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,
index 0e1df42283320c6d75979484296ba3d2aed4f1e9..7f937f72ec0a1afbceffe397ab9db81d62bfeab6 100644 (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. */