1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-07 04:02:58 +03:00

Add info to debug logging.

Avoid null pointer dereference by returning if we can't get
a lua VM.
Move "we got a VM" message to after we know we have one.
Check that we found the lua handler function before trying to
call it.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@939987 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Daniel Earl Poirier
2010-05-01 12:04:27 +00:00
parent c9fc37b35b
commit 1f4b662ca5

View File

@@ -129,21 +129,32 @@ static int lua_handler(request_rec *r)
}
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
"request details scope:%u, cache:%u", d->spec->scope,
d->spec->code_cache_style);
"request details scope:%u, cache:%u, filename:%s, function:%s",
d->spec->scope,
d->spec->code_cache_style,
d->spec->file,
d->function_name);
L = ap_lua_get_lua_state(r->pool,
d->spec,
cfg->package_paths,
cfg->package_cpaths,
&lua_open_callback, NULL);
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "got a vm!");
if (!L) {
/* TODO annotate spec with failure reason */
r->status = HTTP_INTERNAL_SERVER_ERROR;
ap_rputs("Unable to compile VM, see logs", r);
return HTTP_INTERNAL_SERVER_ERROR;
}
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "got a vm!");
lua_getglobal(L, d->function_name);
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);
return HTTP_INTERNAL_SERVER_ERROR;
}
ap_lua_run_lua_request(L, r);
if (lua_pcall(L, 1, 0, 0)) {
report_lua_error(L, r);