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/04/26 23:42:23 UTC

svn commit: r651862 - in /httpd/mod_wombat/trunk: README mod_wombat.c mod_wombat.h

Author: brianm
Date: Sat Apr 26 14:42:21 2008
New Revision: 651862

URL: http://svn.apache.org/viewvc?rev=651862&view=rev
Log:
Allow specifying lua_State scope in the directry config via LuaScope directive

Modified:
    httpd/mod_wombat/trunk/README
    httpd/mod_wombat/trunk/mod_wombat.c
    httpd/mod_wombat/trunk/mod_wombat.h

Modified: httpd/mod_wombat/trunk/README
URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/README?rev=651862&r1=651861&r2=651862&view=diff
==============================================================================
--- httpd/mod_wombat/trunk/README (original)
+++ httpd/mod_wombat/trunk/README Sat Apr 26 14:42:21 2008
@@ -7,19 +7,20 @@
     For now, see docs/building-from-subversion.txt
 
 TODO:
-    Vastly improve writing-handlers.txt
-    
-    Add docs on configuring via the LuaConfig directive
-    
-    Add docs for arbitrary hooks
-        Probably a specific authz tutorial as well
-    
+
+    Move most of the server scoped config into directory config
+
+    Change to controlling lifecycle by passing in a pool?
+        Need to determine how to handle server scoped then!
+
     Provide means to get useful output from lua errors in response body
         Probably have to put it on the vm spec for pre-handler
         errors, as it is pre-handler, will prolly be on the request_config
         somewhere, but sometimes cannot put there, so... fun
         
     Filters
+
+    Better apr table binding
     
     Mapping in the server_rec
     
@@ -49,4 +50,5 @@
     Paul Querna
     Garrett Rooney
     Martin Traverso
-    Brian Akins    
+    Brian Akins
+    Justin Erenkrantz

Modified: httpd/mod_wombat/trunk/mod_wombat.c
URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/mod_wombat.c?rev=651862&r1=651861&r2=651862&view=diff
==============================================================================
--- httpd/mod_wombat/trunk/mod_wombat.c (original)
+++ httpd/mod_wombat/trunk/mod_wombat.c Sat Apr 26 14:42:21 2008
@@ -87,7 +87,7 @@
     }
     
     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "handling [%s] in mod_wombat", r->filename);
-    
+    apw_dir_cfg *dcfg = ap_get_module_config(r->per_dir_config, &wombat_module);
     if (!r->header_only) {        
         apw_request_cfg* rcfg = ap_get_module_config(r->request_config, &wombat_module);
         mapped_request_details *d = rcfg->mapped_request_details;
@@ -95,7 +95,7 @@
         if (!d) {
             d = apr_palloc(r->pool, sizeof(mapped_request_details));
             spec = apr_palloc(r->pool, sizeof(apw_vm_spec));
-            spec->scope = APW_SCOPE_ONCE;
+            spec->scope = dcfg->vm_scope;
             spec->pool = r->pool;
             spec->file = r->filename;
             spec->code_cache_style = APW_CODE_CACHE_STAT;
@@ -212,7 +212,7 @@
     apw_mapped_handler_spec *spec = apr_palloc(cmd->pool, sizeof(apw_mapped_handler_spec));
     spec->file_name = apr_pstrdup(cmd->pool, file);
     spec->function_name = apr_pstrdup(cmd->pool, function);
-    spec->scope = APW_SCOPE_ONCE;
+    spec->scope = cfg->vm_scope;
     spec->code_cache_style = APW_CODE_CACHE_STAT;
     /*
         int code_cache_style;
@@ -359,6 +359,29 @@
     return NULL;
 }
 
+static const char* register_lua_scope(cmd_parms *cmd, void *_cfg, const char *arg) {
+    apw_dir_cfg* cfg = (apw_dir_cfg*)_cfg;
+    if (apr_strnatcmp("once", arg) == 0) {
+        cfg->vm_scope = APW_SCOPE_ONCE;
+    }
+    else if (apr_strnatcmp("request", arg) == 0) {
+        cfg->code_cache_style = APW_SCOPE_REQUEST;
+    }
+    else if (apr_strnatcmp("conn", arg) == 0) {
+        cfg->code_cache_style = APW_SCOPE_CONN;
+    }
+    else if (apr_strnatcmp("server", arg) == 0) {
+        cfg->code_cache_style = APW_SCOPE_SERVER;
+    }
+    else {
+        return apr_psprintf(cmd->pool, 
+               "Invalid value for LuaScope, '%s', acceptable values are %s", 
+               arg, "'once', 'request', 'conn', and 'server'");
+    }
+    return NULL;
+}
+
+
 /**
  * Called for config directive which looks like
  * AddLuaHandler /alias /path/to/lua/file.lua [handler_function_name]
@@ -435,6 +458,9 @@
     AP_INIT_TAKE1("LuaCodeCache", register_code_cache, NULL, OR_ALL, 
                   "Configure the compiled code cache. \
                    Default is to stat the file each time, options are stat|forever|never"),
+                   
+    AP_INIT_TAKE1("LuaScope", register_lua_scope, NULL, OR_ALL,
+                  "One of once, request, conn, server -- default is once"),
 
     AP_INIT_TAKE2("LuaQuickHandler", register_quick_hook, NULL, OR_ALL, 
                   "Provide a hook for the quick handler of request processing"),
@@ -451,6 +477,7 @@
     cfg->pool = p;
     cfg->hooks = apr_hash_make(p);
     cfg->dir = apr_pstrdup(p, dir);
+    cfg->vm_scope = APW_SCOPE_ONCE;
     return cfg;
 }
 

Modified: httpd/mod_wombat/trunk/mod_wombat.h
URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/mod_wombat.h?rev=651862&r1=651861&r2=651862&view=diff
==============================================================================
--- httpd/mod_wombat/trunk/mod_wombat.h (original)
+++ httpd/mod_wombat/trunk/mod_wombat.h Sat Apr 26 14:42:21 2008
@@ -79,6 +79,11 @@
      */ 
     unsigned int code_cache_style;
     
+    /** 
+     * APW_SCOPE_ONCE | APW_SCOPE_REQUEST | APW_SCOPE_CONN | APW_SCOPE_SERVER
+     */
+    int vm_scope;
+    
     // info for the hook harnesses 
     apr_hash_t *hooks; // <wombat_hook_info>