You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by br...@apache.org on 2008/11/02 20:04:28 UTC

svn commit: r709908 - /httpd/mod_wombat/trunk/vmprep.c

Author: brianm
Date: Sun Nov  2 11:04:28 2008
New Revision: 709908

URL: http://svn.apache.org/viewvc?rev=709908&view=rev
Log:
fix a segfault where scope=server and nt using a matched handler

Modified:
    httpd/mod_wombat/trunk/vmprep.c

Modified: httpd/mod_wombat/trunk/vmprep.c
URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/vmprep.c?rev=709908&r1=709907&r2=709908&view=diff
==============================================================================
--- httpd/mod_wombat/trunk/vmprep.c (original)
+++ httpd/mod_wombat/trunk/vmprep.c Sun Nov  2 11:04:28 2008
@@ -80,26 +80,6 @@
     }
 }
 
-void registerlib(lua_State* L, char* name, lua_CFunction f) {
-    lua_getglobal(L, "package");
-    lua_getfield(L, -1, "preload");
-    lua_pushcfunction(L, f);
-    lua_setfield(L, -2, name);
-    lua_pop(L, 2);
-}
-
-
-void open_lualibs(lua_State* L) {
-    lua_cpcall(L, luaopen_base, NULL);
-    lua_cpcall(L, luaopen_package, NULL);
-    registerlib(L, "io", luaopen_io);
-    registerlib(L, "os", luaopen_os);
-    registerlib(L, "table", luaopen_table);
-    registerlib(L, "string", luaopen_string);
-    registerlib(L, "math", luaopen_math);
-    registerlib(L, "debug", luaopen_debug);
-}
-
 /* BEGIN modules*/
 
 /* BEGIN apache lmodule  */
@@ -238,10 +218,6 @@
   return APR_SUCCESS;
 }
 
-
-
-
-
 static void munge_path(lua_State *L, const char *field,
                        const char *sub_pat, const char *rep_pat,
                        apr_pool_t *pool, apr_array_header_t *paths, 
@@ -269,20 +245,19 @@
 }
 
 
-
 /**
- * pool is a working pool or lifecycle pool?
+ * pool is a working pool
  */
 static lua_State* create_vm(apw_vm_spec *spec, 
                             apw_code_cache *cache, 
                             apr_pool_t *pool) {
     lua_State* L =  luaL_newstate();
-    open_lualibs(L);    
+    luaL_openlibs(L);
+    
     apw_run_wombat_open(L, pool);
 
     munge_path(L, "path", "?.lua", "./?.lua", pool, spec->package_paths, spec->file);
     munge_path(L, "cpath", "?.so", "./?.so", pool, spec->package_cpaths, spec->file);
-
     
     if (load_file(pool, L, cache, spec)) {
         ap_log_perror(APLOG_MARK, APLOG_ERR, 0, pool, 
@@ -304,7 +279,7 @@
     apw_server_cfg *cfg = ap_get_module_config(params->server->module_config, &wombat_module);    
     lua_State *L = create_vm(params->spec, cfg->code_cache, pool);
     *resource = L;
-    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, params->server, "L is %d", (int)L);
+    // ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, params->server, "L is %d", (int)L);
     return OK;
 }
 
@@ -346,6 +321,7 @@
             params->spec->code_cache_style = spec->code_cache_style;
             params->spec->scope = APW_SCOPE_SERVER;
             params->spec->package_paths = spec->package_paths;
+            params->spec->package_cpaths = spec->package_cpaths;
             ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server, "Creating reslist for %s", spec->file);
             rv = apr_reslist_create(&rlist,      // the list
                                     10, 100, 100, // min, soft max, hard max
@@ -354,6 +330,7 @@
                                     server_vm_dtor,
                                     params,
                                     server->process->pconf);
+
             apr_hash_set(cfg->vm_reslists, params->spec->file, APR_HASH_KEY_STRING, (void*)rlist);
         }
         apr_thread_rwlock_unlock(cfg->vm_reslists_lock);
@@ -465,8 +442,7 @@
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, server, "ALLOCATING A LUA");
     // TODO change to use load_file
     lua_State* L = luaL_newstate();
-    
-    open_lualibs(L);    
+    luaL_openlibs(L);
     apw_load_apache2_lmodule(L);
     apw_load_config_lmodule(L);
     
@@ -586,7 +562,7 @@
                 ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, working_pool, "file is stale: %s ", spec->file);
                 stale = 1;
             }
-        }	
+        }    
 
         if (!stale) {
             ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, working_pool, "loading from cache: %s", spec->file);