From 0078bfcb437ac4b54cdcaa363e56f7c6dad06ff0 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 7 Oct 2015 20:20:28 +0200 Subject: [PATCH] BUG/MEDIUM: lua: force server-close mode on Lua services Thierry reported that keep-alive still didn't cope well with Lua services. The reason is that for now applets have to be closed at the end of a transaction so we want to work in server-close mode, which isn't noticeable by the client since it still sees keep-alive. Additionally we want to enable the request body transfer analyser which will be needed to synchronize with the response analyser to indicate the end of the transfer. --- src/hlua.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/hlua.c b/src/hlua.c index ae3fe8938..9bfe34d1f 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -5755,6 +5755,16 @@ static int hlua_applet_http_init(struct appctx *ctx, struct proxy *px, struct st txn = strm->txn; msg = &txn->req; + /* We want two things in HTTP mode : + * - enforce server-close mode if we were in keep-alive, so that the + * applet is released after each response ; + * - enable request body transfer to the applet in order to resync + * with the response body. + */ + if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL) + txn->flags = (txn->flags & ~TX_CON_WANT_MSK) | TX_CON_WANT_SCL; + req->analysers |= AN_REQ_HTTP_XFER_BODY; + HLUA_INIT(hlua); ctx->ctx.hlua_apphttp.left_bytes = -1; ctx->ctx.hlua_apphttp.flags = 0;