]> granicus.if.org Git - apache/commitdiff
Add info to debug logging.
authorDaniel Earl Poirier <poirier@apache.org>
Sat, 1 May 2010 12:04:27 +0000 (12:04 +0000)
committerDaniel Earl Poirier <poirier@apache.org>
Sat, 1 May 2010 12:04:27 +0000 (12:04 +0000)
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

modules/lua/mod_lua.c

index 9c97a62587a7c3f52d2b85da174a2fc3763aa8ff..e40df7c38092f9c3d4923373ebc2a178370b3078 100644 (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);