mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
remove some debug logging which snuck in
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1200614 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -39,16 +39,16 @@ static cmd_parms *check_cmd_parms(lua_State *L, int index)
|
||||
static int apl_toscope(const char *name)
|
||||
{
|
||||
if (0 == strcmp("once", name))
|
||||
return APL_SCOPE_ONCE;
|
||||
return AP_LUA_SCOPE_ONCE;
|
||||
if (0 == strcmp("request", name))
|
||||
return APL_SCOPE_REQUEST;
|
||||
return AP_LUA_SCOPE_REQUEST;
|
||||
if (0 == strcmp("connection", name))
|
||||
return APL_SCOPE_CONN;
|
||||
return AP_LUA_SCOPE_CONN;
|
||||
if (0 == strcmp("conn", name))
|
||||
return APL_SCOPE_CONN;
|
||||
return AP_LUA_SCOPE_CONN;
|
||||
if (0 == strcmp("server", name))
|
||||
return APL_SCOPE_SERVER;
|
||||
return APL_SCOPE_ONCE;
|
||||
return AP_LUA_SCOPE_SERVER;
|
||||
return AP_LUA_SCOPE_ONCE;
|
||||
}
|
||||
|
||||
AP_LUA_DECLARE(apr_status_t) ap_lua_map_handler(ap_lua_dir_cfg *cfg,
|
||||
@@ -114,7 +114,7 @@ static int cfg_lua_map_handler(lua_State *L)
|
||||
handler->scope = apl_toscope(scope);
|
||||
}
|
||||
else {
|
||||
handler->scope = APL_SCOPE_ONCE;
|
||||
handler->scope = AP_LUA_SCOPE_ONCE;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
@@ -260,7 +260,6 @@ static int cmd_trace8(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const struct luaL_Reg cmd_methods[] = {
|
||||
{"foo", cmd_foo},
|
||||
|
||||
|
@@ -283,21 +283,19 @@ static void munge_path(lua_State *L,
|
||||
|
||||
parent_dir = ap_make_dirstr_parent(pool, file);
|
||||
|
||||
ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, NULL, "parent_dir %s", parent_dir);
|
||||
|
||||
pattern = apr_pstrcat(pool, parent_dir, sub_pat, NULL);
|
||||
ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, NULL, "pattern %s", pattern);
|
||||
|
||||
luaL_gsub(L, current, rep_pat, pattern);
|
||||
lua_setfield(L, -3, field);
|
||||
lua_getfield(L, -2, field);
|
||||
modified = lua_tostring(L, -1);
|
||||
ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, NULL, "modified %s", modified);
|
||||
|
||||
|
||||
lua_pop(L, 2);
|
||||
|
||||
part = apr_pstrcat(pool, modified, ";", apr_array_pstrcat(pool, paths, ';'),
|
||||
NULL);
|
||||
ap_log_perror(APLOG_MARK, APLOG_WARNING, 0, NULL, "part %s", part);
|
||||
|
||||
lua_pushstring(L, part);
|
||||
lua_setfield(L, -2, field);
|
||||
lua_pop(L, 1); /* pop "package" off the stack */
|
||||
@@ -420,12 +418,17 @@ static apr_status_t vm_reslist_destroy(void *data)
|
||||
return apr_reslist_destroy(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to create a lua_State instance bound into the web
|
||||
* server in the appropriate scope.
|
||||
*/
|
||||
AP_LUA_DECLARE(lua_State*)ap_lua_get_lua_state(apr_pool_t *lifecycle_pool,
|
||||
ap_lua_vm_spec *spec)
|
||||
{
|
||||
lua_State *L = NULL;
|
||||
|
||||
if (spec->scope == APL_SCOPE_SERVER) {
|
||||
/*
|
||||
if (spec->scope == AP_LUA_SCOPE_SERVER) {
|
||||
apr_reslist_t *reslist;
|
||||
|
||||
if (apr_pool_userdata_get((void **)&reslist,
|
||||
@@ -454,6 +457,7 @@ AP_LUA_DECLARE(lua_State*)ap_lua_get_lua_state(apr_pool_t *lifecycle_pool,
|
||||
apr_pool_userdata_set(L, spec->file, vm_release, lifecycle_pool);
|
||||
}
|
||||
} else {
|
||||
*/
|
||||
if (apr_pool_userdata_get((void **)&L, spec->file,
|
||||
lifecycle_pool) == APR_SUCCESS) {
|
||||
|
||||
@@ -462,12 +466,15 @@ AP_LUA_DECLARE(lua_State*)ap_lua_get_lua_state(apr_pool_t *lifecycle_pool,
|
||||
"creating lua_State with file %s", spec->file);
|
||||
/* not available, so create */
|
||||
|
||||
if(!vm_construct((void **)&L, spec, lifecycle_pool))
|
||||
apr_pool_userdata_set(L, spec->file, cleanup_lua,
|
||||
if(!vm_construct((void **)&L, spec, lifecycle_pool)) {
|
||||
apr_pool_userdata_set(L,
|
||||
spec->file,
|
||||
cleanup_lua,
|
||||
lifecycle_pool);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*}*/
|
||||
|
||||
return L;
|
||||
}
|
||||
|
@@ -34,28 +34,11 @@
|
||||
#ifndef VMPREP_H
|
||||
#define VMPREP_H
|
||||
|
||||
#define APL_CODE_CACHE_STAT 1
|
||||
#define APL_CODE_CACHE_FOREVER 2
|
||||
#define APL_CODE_CACHE_NEVER 3
|
||||
#define AP_LUA_SCOPE_ONCE 1
|
||||
#define AP_LUA_SCOPE_REQUEST 2
|
||||
#define AP_LUA_SCOPE_CONN 3
|
||||
#define AP_LUA_SCOPE_SERVER 4
|
||||
|
||||
#define APL_SCOPE_ONCE 1
|
||||
#define APL_SCOPE_REQUEST 2
|
||||
#define APL_SCOPE_CONN 3
|
||||
#define APL_SCOPE_SERVER 4
|
||||
|
||||
|
||||
/**
|
||||
* the ap_lua_?getvm family of functions is used to create and/or obtain
|
||||
* a handle to a lua state. If there is not an extant vm matching the
|
||||
* spec then a new one is created.
|
||||
*/
|
||||
/* lua_State* ap_lua_rgetvm(request_rec *r, ap_lua_vm_spec *spec); */
|
||||
|
||||
/* returns NULL if the spec requires a request scope */
|
||||
/* lua_State* ap_lua_cgetvm(conn_rec *r, ap_lua_vm_spec *spec);*/
|
||||
|
||||
/* returns NULL if the spec requires a request scope or conn scope */
|
||||
/* lua_State* ap_lua_sgetvm(server_rec *r, ap_lua_vm_spec *spec); */
|
||||
|
||||
typedef void (*ap_lua_state_open_callback) (lua_State *L, apr_pool_t *p,
|
||||
void *ctx);
|
||||
@@ -65,7 +48,6 @@ typedef void (*ap_lua_state_open_callback) (lua_State *L, apr_pool_t *p,
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
/* NEED TO ADD ADDITIONAL PACKAGE PATHS AS PART OF SPEC INSTEAD OF DIR CONFIG */
|
||||
apr_array_header_t *package_paths;
|
||||
apr_array_header_t *package_cpaths;
|
||||
@@ -73,9 +55,6 @@ typedef struct
|
||||
/* name of base file to load in the vm */
|
||||
char *file;
|
||||
|
||||
/* APL_CODE_CACHE_STAT | APL_CODE_CACHE_FOREVER | APL_CODE_CACHE_NEVER */
|
||||
int code_cache_style;
|
||||
|
||||
/* APL_SCOPE_ONCE | APL_SCOPE_REQUEST | APL_SCOPE_CONN | APL_SCOPE_SERVER */
|
||||
int scope;
|
||||
unsigned int vm_server_pool_min;
|
||||
@@ -83,6 +62,7 @@ typedef struct
|
||||
|
||||
ap_lua_state_open_callback cb;
|
||||
void* cb_arg;
|
||||
|
||||
/* pool to use for lifecycle if APL_SCOPE_ONCE is set, otherwise unused */
|
||||
apr_pool_t *pool;
|
||||
|
||||
@@ -96,7 +76,6 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int code_cache_style;
|
||||
char *function_name;
|
||||
char *file_name;
|
||||
int scope;
|
||||
@@ -105,13 +84,6 @@ typedef struct
|
||||
apr_size_t bytecode_len;
|
||||
} ap_lua_mapped_handler_spec;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
apr_pool_t *pool;
|
||||
apr_hash_t *compiled_files;
|
||||
apr_thread_rwlock_t *compiled_files_lock;
|
||||
} ap_lua_code_cache;
|
||||
|
||||
/* remove and make static once out of mod_wombat.c */
|
||||
AP_LUA_DECLARE(void) ap_lua_openlibs(lua_State *L);
|
||||
|
||||
|
@@ -74,32 +74,6 @@ static int lua_open_hook(lua_State *L, apr_pool_t *p)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
static apr_status_t luahood(ap_filter_t *f, apr_bucket_brigade *bb) {
|
||||
apr_bucket* b;
|
||||
apr_status_t rs;
|
||||
for ( b = APR_BRIGADE_FIRST(bb);
|
||||
b != APR_BRIGADE_SENTINEL(bb);
|
||||
b = APR_BUCKET_NEXT(b))
|
||||
{
|
||||
if (APR_BUCKET_IS_EOS(b)) {kl
|
||||
break;
|
||||
}
|
||||
const char *buffer;
|
||||
size_t bytes;
|
||||
if (( rs = apr_bucket_read(b, &buffer, &bytes, APR_BLOCK_READ))) {
|
||||
ap_log_rerror(APLOG_MARK, APLOG_WARNING, rs, f->r, "read failure in luahood");
|
||||
return rs;
|
||||
}
|
||||
char *mine = apr_pstrmemdup(f->r->pool, buffer, bytes);
|
||||
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, f->r, "sending '%s'", mine);
|
||||
}
|
||||
|
||||
ap_pass_brigade(f->next, bb);
|
||||
|
||||
return OK;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* "main"
|
||||
@@ -121,14 +95,12 @@ static int lua_handler(request_rec *r)
|
||||
&lua_module);
|
||||
ap_lua_request_cfg *rcfg = ap_get_module_config(r->request_config,
|
||||
&lua_module);
|
||||
mapped_request_details *d = rcfg->mapped_request_details;
|
||||
|
||||
ap_lua_vm_spec *spec = NULL;
|
||||
|
||||
if (!d) {
|
||||
d = apr_palloc(r->pool, sizeof(mapped_request_details));
|
||||
spec = apr_pcalloc(r->pool, sizeof(ap_lua_vm_spec));
|
||||
spec->scope = dcfg->vm_scope;
|
||||
spec->pool = spec->scope==APL_SCOPE_SERVER ? cfg->pool : r->pool;
|
||||
spec->pool = spec->scope==AP_LUA_SCOPE_SERVER ? cfg->pool : r->pool;
|
||||
spec->file = r->filename;
|
||||
spec->package_paths = cfg->package_paths;
|
||||
spec->package_cpaths = cfg->package_cpaths;
|
||||
@@ -136,17 +108,14 @@ static int lua_handler(request_rec *r)
|
||||
spec->vm_server_pool_max = cfg->vm_server_pool_max;
|
||||
spec->cb = &lua_open_callback;
|
||||
spec->cb_arg = NULL;
|
||||
d->spec = spec;
|
||||
d->function_name = "handle";
|
||||
}
|
||||
|
||||
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
|
||||
"request details scope:%u, filename:%s, function:%s",
|
||||
d->spec->scope,
|
||||
d->spec->file,
|
||||
d->function_name);
|
||||
spec->scope,
|
||||
spec->file,
|
||||
"handle");
|
||||
L = ap_lua_get_lua_state(r->pool,
|
||||
d->spec);
|
||||
spec);
|
||||
|
||||
if (!L) {
|
||||
/* TODO annotate spec with failure reason */
|
||||
@@ -155,12 +124,12 @@ static int lua_handler(request_rec *r)
|
||||
return HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "got a vm!");
|
||||
lua_getglobal(L, d->function_name);
|
||||
lua_getglobal(L, "handle");
|
||||
if (!lua_isfunction(L, -1)) {
|
||||
ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r,
|
||||
"lua: Unable to find function %s in %s",
|
||||
d->function_name,
|
||||
d->spec->file);
|
||||
"handle",
|
||||
spec->file);
|
||||
return HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
ap_lua_run_lua_request(L, r);
|
||||
@@ -173,55 +142,6 @@ static int lua_handler(request_rec *r)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Like mod_alias except for lua handler fun :-)
|
||||
*/
|
||||
static int lua_alias_munger(request_rec *r)
|
||||
{
|
||||
ap_lua_vm_spec *spec;
|
||||
ap_lua_request_cfg *rcfg = ap_get_module_config(r->request_config,
|
||||
&lua_module);
|
||||
const ap_lua_dir_cfg *cfg = ap_get_module_config(r->per_dir_config,
|
||||
&lua_module);
|
||||
int i;
|
||||
ap_regmatch_t matches[AP_MAX_REG_MATCH];
|
||||
|
||||
for (i = 0; i < cfg->mapped_handlers->nelts; i++) {
|
||||
const ap_lua_mapped_handler_spec *cnd =
|
||||
((const ap_lua_mapped_handler_spec **) cfg->mapped_handlers->elts)[i];
|
||||
|
||||
if (OK == ap_regexec(cnd->uri_pattern, r->uri, AP_MAX_REG_MATCH,
|
||||
matches, 0)) {
|
||||
mapped_request_details *d;
|
||||
r->handler = "lua-script";
|
||||
|
||||
spec = apr_pcalloc(r->pool, sizeof(ap_lua_vm_spec));
|
||||
spec->file = ap_pregsub(r->pool, cnd->file_name, r->uri,
|
||||
AP_MAX_REG_MATCH, matches);
|
||||
spec->scope = cnd->scope;
|
||||
spec->bytecode = cnd->bytecode;
|
||||
spec->bytecode_len = cnd->bytecode_len;
|
||||
if (spec->scope == APL_SCOPE_ONCE) {
|
||||
spec->pool = r->pool;
|
||||
}
|
||||
|
||||
spec->cb = &lua_open_callback;
|
||||
spec->cb_arg = NULL;
|
||||
|
||||
d = apr_palloc(r->pool, sizeof(mapped_request_details));
|
||||
|
||||
d->function_name = ap_pregsub(r->pool, cnd->function_name, r->uri,
|
||||
AP_MAX_REG_MATCH, matches);
|
||||
d->spec = spec;
|
||||
|
||||
/* now do replacement on method name where? */
|
||||
r->filename = apr_pstrdup(r->pool, spec->file);
|
||||
rcfg->mapped_request_details = d;
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
return DECLINED;
|
||||
}
|
||||
|
||||
/* ---------------- Configury stuff --------------- */
|
||||
|
||||
@@ -256,7 +176,7 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name, int ap
|
||||
spec->vm_server_pool_max = cfg->vm_server_pool_max;
|
||||
spec->bytecode = hook_spec->bytecode;
|
||||
spec->bytecode_len = hook_spec->bytecode_len;
|
||||
spec->pool = spec->scope==APL_SCOPE_SERVER ? cfg->pool : r->pool;
|
||||
spec->pool = spec->scope==AP_LUA_SCOPE_SERVER ? cfg->pool : r->pool;
|
||||
spec->package_paths = cfg->package_paths;
|
||||
spec->package_cpaths = cfg->package_cpaths;
|
||||
spec->cb = &lua_open_callback;
|
||||
@@ -912,16 +832,16 @@ static const char *register_lua_scope(cmd_parms *cmd,
|
||||
{
|
||||
ap_lua_dir_cfg *cfg = (ap_lua_dir_cfg *) _cfg;
|
||||
if (strcmp("once", scope) == 0) {
|
||||
cfg->vm_scope = APL_SCOPE_ONCE;
|
||||
cfg->vm_scope = AP_LUA_SCOPE_ONCE;
|
||||
}
|
||||
else if (strcmp("request", scope) == 0) {
|
||||
cfg->vm_scope = APL_SCOPE_REQUEST;
|
||||
cfg->vm_scope = AP_LUA_SCOPE_REQUEST;
|
||||
}
|
||||
else if (strcmp("conn", scope) == 0) {
|
||||
cfg->vm_scope = APL_SCOPE_CONN;
|
||||
cfg->vm_scope = AP_LUA_SCOPE_CONN;
|
||||
}
|
||||
else if (strcmp("server", scope) == 0) {
|
||||
cfg->vm_scope = APL_SCOPE_SERVER;
|
||||
cfg->vm_scope = AP_LUA_SCOPE_SERVER;
|
||||
if (min)
|
||||
cfg->vm_server_pool_min = atoi(min);
|
||||
if (max)
|
||||
@@ -938,27 +858,6 @@ static const char *register_lua_scope(cmd_parms *cmd,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called for config directive which looks like
|
||||
* AddLuaHandler /alias /path/to/lua/file.lua [handler_function_name]
|
||||
*/
|
||||
static const char *lua_map_handler(cmd_parms *cmd, void *_cfg,
|
||||
const char *path, const char *file,
|
||||
const char *function)
|
||||
{
|
||||
ap_lua_dir_cfg *cfg = (ap_lua_dir_cfg *) _cfg;
|
||||
apr_status_t rv;
|
||||
const char *function_name;
|
||||
function_name = function ? function : "handle";
|
||||
rv = ap_lua_map_handler(cfg, file, function_name, path, "once");
|
||||
if (rv != APR_SUCCESS) {
|
||||
return apr_psprintf(cmd->pool,
|
||||
"Unable to configure a lua handler for path "
|
||||
"'%s', handler %s#%s",
|
||||
path, file, function_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *register_lua_root(cmd_parms *cmd, void *_cfg,
|
||||
const char *root)
|
||||
@@ -996,12 +895,11 @@ command_rec lua_commands[] = {
|
||||
AP_INIT_TAKE1("LuaPackageCPath", register_package_cdir, NULL, OR_ALL,
|
||||
"Add a directory to lua's package.cpath"),
|
||||
|
||||
AP_INIT_TAKE23("LuaMapHandler", lua_map_handler, NULL, OR_ALL,
|
||||
"Map a path to a lua handler"),
|
||||
|
||||
AP_INIT_TAKE23("LuaHookTranslateName", register_translate_name_hook, NULL,
|
||||
OR_ALL,
|
||||
"Provide a hook for the translate name phase of request processing"),
|
||||
|
||||
AP_INIT_RAW_ARGS("<LuaHookTranslateName", register_translate_name_block,
|
||||
NULL,
|
||||
EXEC_ON_READ | OR_ALL,
|
||||
@@ -1086,7 +984,7 @@ static void *create_dir_config(apr_pool_t *p, char *dir)
|
||||
cfg->pool = p;
|
||||
cfg->hooks = apr_hash_make(p);
|
||||
cfg->dir = apr_pstrdup(p, dir);
|
||||
cfg->vm_scope = APL_SCOPE_ONCE;
|
||||
cfg->vm_scope = AP_LUA_SCOPE_ONCE;
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@@ -1170,7 +1068,6 @@ static void lua_register_hooks(apr_pool_t *p)
|
||||
APR_HOOK_MIDDLE);
|
||||
ap_hook_quick_handler(lua_quick_harness, NULL, NULL, APR_HOOK_FIRST);
|
||||
|
||||
ap_hook_translate_name(lua_alias_munger, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
ap_hook_post_config(lua_post_config, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
|
||||
APR_OPTIONAL_HOOK(ap_lua, lua_open, lua_open_hook, NULL, NULL,
|
||||
|
@@ -94,7 +94,7 @@ typedef struct
|
||||
apr_pool_t *pool;
|
||||
|
||||
/**
|
||||
* APL_SCOPE_ONCE | APL_SCOPE_REQUEST | APL_SCOPE_CONN | APL_SCOPE_SERVER
|
||||
* AP_LUA_SCOPE_ONCE | AP_LUA_SCOPE_REQUEST | AP_LUA_SCOPE_CONN | AP_LUA_SCOPE_SERVER
|
||||
*/
|
||||
unsigned int vm_scope;
|
||||
unsigned int vm_server_pool_min;
|
||||
@@ -109,7 +109,6 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ap_lua_code_cache *code_cache;
|
||||
apr_hash_t *vm_reslists;
|
||||
apr_thread_rwlock_t *vm_reslists_lock;
|
||||
|
||||
|
Reference in New Issue
Block a user