845520e
diff --git a/modules/lua/config.m4 b/modules/lua/config.m4
845520e
index 29fd563..abeba1c 100644
845520e
--- a/modules/lua/config.m4
845520e
+++ b/modules/lua/config.m4
845520e
@@ -34,7 +34,7 @@ AC_DEFUN([CHECK_LUA_PATH], [dnl
845520e
     fi
845520e
 ])
845520e
 
845520e
-dnl Check for Lua 5.3/5.2/5.1 Libraries
845520e
+dnl Check for Lua Libraries
845520e
 dnl CHECK_LUA(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
845520e
 dnl Sets:
845520e
 dnl  LUA_CFLAGS
845520e
@@ -44,7 +44,7 @@ AC_DEFUN([CHECK_LUA],
845520e
 
845520e
 AC_ARG_WITH(
845520e
     lua,
845520e
-    [AC_HELP_STRING([--with-lua=PATH],[Path to the Lua 5.3/5.2/5.1 prefix])],
845520e
+    [AC_HELP_STRING([--with-lua=PATH],[Path to the Lua installation prefix])],
845520e
     lua_path="$withval",
845520e
     :)
845520e
 
426fad1
diff --git a/modules/lua/mod_lua.c b/modules/lua/mod_lua.c
845520e
index 05f1e44..18b628c 100644
426fad1
--- a/modules/lua/mod_lua.c
426fad1
+++ b/modules/lua/mod_lua.c
426fad1
@@ -342,7 +342,7 @@ static apr_status_t lua_setup_filter_ctx(ap_filter_t* f, request_rec* r, lua_fil
426fad1
 {
426fad1
     apr_pool_t *pool;
426fad1
     ap_lua_vm_spec *spec;
426fad1
-    int n, rc;
426fad1
+    int n, rc, nres;
426fad1
     lua_State *L;
426fad1
     lua_filter_ctx *ctx;    
426fad1
     ap_lua_server_cfg *server_cfg = ap_get_module_config(r->server->module_config,
426fad1
@@ -410,7 +410,7 @@ static apr_status_t lua_setup_filter_ctx(ap_filter_t* f, request_rec* r, lua_fil
426fad1
             /* If a Lua filter is interested in filtering a request, it must first do a yield, 
426fad1
              * otherwise we'll assume that it's not interested and pretend we didn't find it.
426fad1
              */
426fad1
-            rc = lua_resume(L, 1);
426fad1
+            rc = lua_resume(L, 1, &nres);
426fad1
             if (rc == LUA_YIELD) {
426fad1
                 if (f->frec->providers == NULL) { 
426fad1
                     /* Not wired by mod_filter */
426fad1
@@ -432,7 +432,7 @@ static apr_status_t lua_setup_filter_ctx(ap_filter_t* f, request_rec* r, lua_fil
426fad1
 static apr_status_t lua_output_filter_handle(ap_filter_t *f, apr_bucket_brigade *pbbIn)
426fad1
 {
426fad1
     request_rec *r = f->r;
426fad1
-    int rc;
426fad1
+    int rc, nres;
426fad1
     lua_State *L;
426fad1
     lua_filter_ctx* ctx;
426fad1
     conn_rec *c = r->connection;
426fad1
@@ -492,7 +492,7 @@ static apr_status_t lua_output_filter_handle(ap_filter_t *f, apr_bucket_brigade
426fad1
             lua_setglobal(L, "bucket");
426fad1
             
426fad1
             /* If Lua yielded, it means we have something to pass on */
426fad1
-            if (lua_resume(L, 0) == LUA_YIELD) {
845520e
+            if (lua_resume(L, 0, &nres) == LUA_YIELD && nres == 1) {
426fad1
                 size_t olen;
426fad1
                 const char* output = lua_tolstring(L, 1, &olen);
426fad1
                 if (olen > 0) { 
426fad1
@@ -524,7 +524,7 @@ static apr_status_t lua_output_filter_handle(ap_filter_t *f, apr_bucket_brigade
426fad1
             apr_bucket *pbktEOS;
426fad1
             lua_pushnil(L);
426fad1
             lua_setglobal(L, "bucket");
426fad1
-            if (lua_resume(L, 0) == LUA_YIELD) {
845520e
+            if (lua_resume(L, 0, &nres) == LUA_YIELD && nres == 1) {
426fad1
                 apr_bucket *pbktOut;
426fad1
                 size_t olen;
426fad1
                 const char* output = lua_tolstring(L, 1, &olen);
426fad1
@@ -558,7 +558,7 @@ static apr_status_t lua_input_filter_handle(ap_filter_t *f,
426fad1
                                        apr_off_t nBytes) 
426fad1
 {
426fad1
     request_rec *r = f->r;
426fad1
-    int rc, lastCall = 0;
426fad1
+    int rc, lastCall = 0, nres;
426fad1
     lua_State *L;
426fad1
     lua_filter_ctx* ctx;
426fad1
     conn_rec *c = r->connection;
426fad1
@@ -621,7 +621,7 @@ static apr_status_t lua_input_filter_handle(ap_filter_t *f,
426fad1
             lua_setglobal(L, "bucket");
426fad1
             
426fad1
             /* If Lua yielded, it means we have something to pass on */
426fad1
-            if (lua_resume(L, 0) == LUA_YIELD) {
845520e
+            if (lua_resume(L, 0, &nres) == LUA_YIELD && nres == 1) {
426fad1
                 size_t olen;
426fad1
                 const char* output = lua_tolstring(L, 1, &olen);
426fad1
                 pbktOut = apr_bucket_heap_create(output, olen, 0, c->bucket_alloc);
426fad1
@@ -643,7 +643,7 @@ static apr_status_t lua_input_filter_handle(ap_filter_t *f,
426fad1
             apr_bucket *pbktEOS = apr_bucket_eos_create(c->bucket_alloc);
426fad1
             lua_pushnil(L);
426fad1
             lua_setglobal(L, "bucket");
426fad1
-            if (lua_resume(L, 0) == LUA_YIELD) {
845520e
+            if (lua_resume(L, 0, &nres) == LUA_YIELD && nres == 1) {
426fad1
                 apr_bucket *pbktOut;
426fad1
                 size_t olen;
426fad1
                 const char* output = lua_tolstring(L, 1, &olen);
426fad1
diff --git a/modules/lua/mod_lua.h b/modules/lua/mod_lua.h
845520e
index 0e49cdc..72b4de7 100644
426fad1
--- a/modules/lua/mod_lua.h
426fad1
+++ b/modules/lua/mod_lua.h
845520e
@@ -48,7 +48,15 @@
426fad1
 #if LUA_VERSION_NUM > 501
426fad1
 /* Load mode for lua_load() */
426fad1
 #define lua_load(a,b,c,d)  lua_load(a,b,c,d,NULL)
426fad1
-#define lua_resume(a,b)    lua_resume(a, NULL, b)
426fad1
+
426fad1
+#if LUA_VERSION_NUM > 503
426fad1
+#define lua_resume(a,b,c)    lua_resume(a, NULL, b, c)
426fad1
+#else
845520e
+/* ### For version < 5.4, assume that exactly one stack item is on the
845520e
+ * stack, which is what the code did before but seems dubious. */
845520e
+#define lua_resume(a,b,c)    (*(c) = 1, lua_resume(a, NULL, b))
426fad1
+#endif
426fad1
+
426fad1
 #define luaL_setfuncs_compat(a,b) luaL_setfuncs(a,b,0)
426fad1
 #else
426fad1
 #define lua_rawlen(L,i)    lua_objlen(L, (i))