Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 41512 invoked from network); 21 Dec 2008 22:22:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Dec 2008 22:22:16 -0000 Received: (qmail 50954 invoked by uid 500); 21 Dec 2008 22:22:16 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 50895 invoked by uid 500); 21 Dec 2008 22:22:16 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 50886 invoked by uid 99); 21 Dec 2008 22:22:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Dec 2008 14:22:16 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Dec 2008 22:22:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4733B2388878; Sun, 21 Dec 2008 14:21:55 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r728531 - in /httpd/httpd/trunk/modules/lua: lua_vmprep.c lua_vmprep.h mod_lua.c Date: Sun, 21 Dec 2008 22:21:55 -0000 To: cvs@httpd.apache.org From: pquerna@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081221222155.4733B2388878@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pquerna Date: Sun Dec 21 14:21:54 2008 New Revision: 728531 URL: http://svn.apache.org/viewvc?rev=728531&view=rev Log: Change apl_get_lua_state to take a apl_vm_spec instead of a filename, and to load the bytecode if it is present, rather than the file, as this gets the inline config file blocks hooks working again. Modified: httpd/httpd/trunk/modules/lua/lua_vmprep.c httpd/httpd/trunk/modules/lua/lua_vmprep.h httpd/httpd/trunk/modules/lua/mod_lua.c Modified: httpd/httpd/trunk/modules/lua/lua_vmprep.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_vmprep.c?rev=728531&r1=728530&r2=728531&view=diff ============================================================================== --- httpd/httpd/trunk/modules/lua/lua_vmprep.c (original) +++ httpd/httpd/trunk/modules/lua/lua_vmprep.c Sun Dec 21 14:21:54 2008 @@ -258,7 +258,7 @@ } lua_State *apl_get_lua_state(apr_pool_t *lifecycle_pool, - char *file, + apl_vm_spec *spec, apr_array_header_t *package_paths, apr_array_header_t *package_cpaths, apl_lua_state_open_callback cb, void *btn) @@ -267,29 +267,37 @@ lua_State *L; ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, lifecycle_pool, "obtaining lua_State"); - if (!apr_pool_userdata_get((void **) &L, file, lifecycle_pool)) { + if (!apr_pool_userdata_get((void **) &L, spec->file, lifecycle_pool)) { ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, lifecycle_pool, - "creating lua_State with file %s", file); + "creating lua_State with file %s", spec->file); /* not available, so create */ L = luaL_newstate(); luaL_openlibs(L); if (package_paths) munge_path(L, "path", "?.lua", "./?.lua", lifecycle_pool, - package_paths, file); + package_paths, spec->file); if (package_cpaths) munge_path(L, "cpath", "?.so", "./?.so", lifecycle_pool, - package_cpaths, file); + package_cpaths, spec->file); if (cb) { cb(L, lifecycle_pool, btn); } - luaL_loadfile(L, file); - lua_pcall(L, 0, LUA_MULTRET, 0); - apr_pool_userdata_set(L, file, &cleanup_lua, lifecycle_pool); + apr_pool_userdata_set(L, spec->file, &cleanup_lua, lifecycle_pool); + + if (spec->bytecode && spec->bytecode_len > 0) { + luaL_loadbuffer(L, spec->bytecode, spec->bytecode_len, spec->file); + lua_pcall(L, 0, LUA_MULTRET, 0); + } + else { + luaL_loadfile(L, spec->file); + lua_pcall(L, 0, LUA_MULTRET, 0); + } lua_pushlightuserdata(L, lifecycle_pool); lua_setfield(L, LUA_REGISTRYINDEX, "Apache2.Wombat.pool"); } + return L; } Modified: httpd/httpd/trunk/modules/lua/lua_vmprep.h URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_vmprep.h?rev=728531&r1=728530&r2=728531&view=diff ============================================================================== --- httpd/httpd/trunk/modules/lua/lua_vmprep.h (original) +++ httpd/httpd/trunk/modules/lua/lua_vmprep.h Sun Dec 21 14:21:54 2008 @@ -65,6 +65,10 @@ /* pool to use for lifecycle if APL_SCOPE_ONCE is set, otherwise unused */ apr_pool_t *pool; + /* Pre-compiled Lua Byte code to load directly. If bytecode_len is >0, + * the file part of this structure is ignored for loading purposes, but + * it is used for error messages. + */ const char *bytecode; apr_size_t bytecode_len; } apl_vm_spec; @@ -127,7 +131,7 @@ * @ctx a baton passed to cb */ lua_State *apl_get_lua_state(apr_pool_t *lifecycle_pool, - char *file, + apl_vm_spec *spec, apr_array_header_t *package_paths, apr_array_header_t *package_cpaths, apl_lua_state_open_callback cb, void *btn); Modified: httpd/httpd/trunk/modules/lua/mod_lua.c URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/mod_lua.c?rev=728531&r1=728530&r2=728531&view=diff ============================================================================== --- httpd/httpd/trunk/modules/lua/mod_lua.c (original) +++ httpd/httpd/trunk/modules/lua/mod_lua.c Sun Dec 21 14:21:54 2008 @@ -127,7 +127,7 @@ const apl_dir_cfg *cfg = ap_get_module_config(r->per_dir_config, &lua_module); lua_State *L = apl_get_lua_state(r->pool, - d->spec->file, + d->spec, cfg->package_paths, cfg->package_cpaths, &lua_open_callback, NULL); @@ -206,8 +206,8 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name) { - char *fixed_filename; - + apl_server_cfg *server_cfg = ap_get_module_config(r->server->module_config, + &lua_module); const apl_dir_cfg *cfg = (apl_dir_cfg *) ap_get_module_config(r->per_dir_config, &lua_module); @@ -216,10 +216,13 @@ if (hook_specs) { int i; for (i = 0; i < hook_specs->nelts; i++) { + char *fixed_filename = NULL; apl_mapped_handler_spec *hook_spec = ((apl_mapped_handler_spec **) hook_specs->elts)[i]; - if (hook_spec == NULL) + + if (hook_spec == NULL) { continue; + } apl_vm_spec *spec = apr_pcalloc(r->pool, sizeof(apl_vm_spec)); spec->file = hook_spec->file_name; @@ -229,20 +232,10 @@ spec->bytecode_len = hook_spec->bytecode_len; spec->pool = r->pool; - /* - const apl_dir_cfg* cfg = ap_get_module_config(r->per_dir_config, &lua_module); - lua_State *L = apl_get_lua_state(r->pool, - d->spec->file, - cfg->package_paths, - cfg->package_cpaths, - &lua_open_callback, NULL); - */ - apl_server_cfg *server_cfg = - ap_get_module_config(r->server->module_config, &lua_module); - apr_filepath_merge(&fixed_filename, server_cfg->root_path, + apr_filepath_merge(&spec->file, server_cfg->root_path, spec->file, APR_FILEPATH_NOTRELATIVE, r->pool); lua_State *L = apl_get_lua_state(r->pool, - fixed_filename, + spec, cfg->package_paths, cfg->package_cpaths, &lua_open_callback, NULL);