소스 검색

Fix and test the existing implementation for plain Lua pages

bel 11 년 전
부모
커밋
07beed7bf1
2개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 0
      src/civetweb.c
  2. 2 1
      src/mod_lua.inl

+ 2 - 0
src/civetweb.c

@@ -5135,6 +5135,8 @@ static void handle_request(struct mg_connection *conn)
                             "Directory listing denied");
         }
 #ifdef USE_LUA
+    } else if (match_prefix("**.lsp$", 6, path) > 0) {
+        mg_exec_lua_script(conn, path, NULL);
     } else if (match_prefix("**.lp$", 6, path) > 0) {
         handle_lsp_request(conn, path, &file, NULL);
 #endif

+ 2 - 1
src/mod_lua.inl

@@ -384,8 +384,8 @@ void mg_exec_lua_script(struct mg_connection *conn, const char *path,
         prepare_lua_environment(conn, L, path);
         lua_pushcclosure(L, &lua_error_handler, 0);
 
-        lua_pushglobaltable(L);
         if (exports != NULL) {
+            lua_pushglobaltable(L);
             for (i = 0; exports[i] != NULL && exports[i + 1] != NULL; i += 2) {
                 lua_pushstring(L, exports[i]);
                 lua_pushcclosure(L, (lua_CFunction) exports[i + 1], 0);
@@ -399,6 +399,7 @@ void mg_exec_lua_script(struct mg_connection *conn, const char *path,
         lua_pcall(L, 0, 0, -2);
         lua_close(L);
     }
+    conn->must_close=1;
 }
 
 static void lsp_send_err(struct mg_connection *conn, struct lua_State *L,