Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: CVS

svn commit: r1369494 - in /httpd/httpd/branches/2.4.x: ./ docs/manual/mod/ modules/lua/

 

 

Apache cvs RSS feed   Index | Next | Previous | View Threaded


rjung at apache

Aug 4, 2012, 3:21 PM

Post #1 of 1 (20 views)
Permalink
svn commit: r1369494 - in /httpd/httpd/branches/2.4.x: ./ docs/manual/mod/ modules/lua/

Author: rjung
Date: Sat Aug 4 22:21:56 2012
New Revision: 1369494

URL: http://svn.apache.org/viewvc?rev=1369494&view=rev
Log:
Big mod_lua backport:

r1201460: Add some todos from apachecon notes.
Submitted by: covener

r1351012: Change prototype of vm_construct, to work around gcc bug which
causes a segfault. PR: 52779
Submitted by: Dick Snippe <Dick Snippe tech omroep nl>

r1351013: Allow tail call optimization in log methods, remove foo method.
Submitted by: sf

r1351014: Add a few missing request_rec fields. Rename remote_ip to
client_ip to match conn_rec.
Submitted by: sf

r1351017: Change various strings from char * to const char *.
Submitted by: sf

r1351018: Factor common code into utility function.
Also improve logging a bit and adjust some log levels.
Submitted by: sf

r1351019: Use macro to make definition of integer fields more compact.
Submitted by: sf

Reviewed by: humbedooh, covener, sf
Backported by: humbedooh, rjung

Modified:
httpd/httpd/branches/2.4.x/ (props changed)
httpd/httpd/branches/2.4.x/CHANGES
httpd/httpd/branches/2.4.x/STATUS
httpd/httpd/branches/2.4.x/docs/manual/mod/mod_lua.xml
httpd/httpd/branches/2.4.x/modules/lua/README
httpd/httpd/branches/2.4.x/modules/lua/lua_config.c
httpd/httpd/branches/2.4.x/modules/lua/lua_request.c
httpd/httpd/branches/2.4.x/modules/lua/lua_vmprep.c
httpd/httpd/branches/2.4.x/modules/lua/lua_vmprep.h
httpd/httpd/branches/2.4.x/modules/lua/mod_lua.c
httpd/httpd/branches/2.4.x/modules/lua/mod_lua.h

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
Merged /httpd/httpd/trunk:r1201460,1351012-1351014,1351017-1351019

Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1369494&r1=1369493&r2=1369494&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Sat Aug 4 22:21:56 2012
@@ -7,6 +7,12 @@ Changes with Apache 2.4.3
possible XSS for a site where untrusted users can upload files to
a location with MultiViews enabled. [Niels Heinen <heinenn google.com>]

+ *) mod_lua: Add a few missing request_rec fields. Rename remote_ip to
+ client_ip to match conn_rec. [Stefan Fritsch]
+
+ *) mod_lua: Change prototype of vm_construct, to work around gcc bug which
+ causes a segfault. PR 52779. [Dick Snippe <Dick Snippe tech omroep nl>]
+
*) mpm_event: Don't count connections in lingering close state when
calculating how many additional connections may be accepted.
[Stefan Fritsch]

Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1369494&r1=1369493&r2=1369494&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Sat Aug 4 22:21:56 2012
@@ -88,17 +88,6 @@ RELEASE SHOWSTOPPERS:
PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
[ start all new proposals below, under PATCHES PROPOSED. ]

- * mod_lua: resync 2.4.x with sf's refactoring/fixes in trunk (and Covener's notes)
- trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1201460
- http://svn.apache.org/viewvc?view=revision&revision=1351012
- http://svn.apache.org/viewvc?view=revision&revision=1351013
- http://svn.apache.org/viewvc?view=revision&revision=1351014
- http://svn.apache.org/viewvc?view=revision&revision=1351017
- http://svn.apache.org/viewvc?view=revision&revision=1351018
- http://svn.apache.org/viewvc?view=revision&revision=1351019
- 2.4.x patch: http://people.apache.org/~humbedooh/mod_lua.diff
- http://people.apache.org/~humbedooh/mod_lua_changes.diff
- +1: humbedooh, covener, sf

PATCHES PROPOSED TO BACKPORT FROM TRUNK:
[. New proposals should be added at the end of the list ]

Modified: httpd/httpd/branches/2.4.x/docs/manual/mod/mod_lua.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/mod/mod_lua.xml?rev=1369494&r1=1369493&r2=1369494&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/docs/manual/mod/mod_lua.xml (original)
+++ httpd/httpd/branches/2.4.x/docs/manual/mod/mod_lua.xml Sat Aug 4 22:21:56 2012
@@ -233,6 +233,16 @@ end
<td>string</td>
<td>yes</td>
</tr>
+ <tr>
+ <td><code>context_prefix</code></td>
+ <td>string</td>
+ <td>no</td>
+ </tr>
+ <tr>
+ <td><code>context_document_root</code></td>
+ <td>string</td>
+ <td>no</td>
+ </tr>

<tr>
<td><code>document_root</code></td>
@@ -271,6 +281,11 @@ end
<td>no</td>
</tr>
<tr>
+ <td><code>log_id</code></td>
+ <td>string</td>
+ <td>no</td>
+ </tr>
+ <tr>
<td><code>method</code></td>
<td>string</td>
<td>no</td>
@@ -330,6 +345,11 @@ end
<td>string</td>
<td>yes</td>
</tr>
+ <tr>
+ <td><code>useragent_ip</code></td>
+ <td>string</td>
+ <td>no</td>
+ </tr>
</table>

<p>The request_rec has (at least) the following methods:</p>

Modified: httpd/httpd/branches/2.4.x/modules/lua/README
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/lua/README?rev=1369494&r1=1369493&r2=1369494&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/lua/README (original)
+++ httpd/httpd/branches/2.4.x/modules/lua/README Sat Aug 4 22:21:56 2012
@@ -54,6 +54,13 @@
** TODO apw_rgetvm needs to handle connection scoped vms
** TODO options in server scoped vms (ie, min and max vm counts)
** TODO provide means to implement authn and authz providers
+** TODO: Flatten LuaHook* to LuaHook phase file fn ?
+** TODO: Lua and ap_expr integration in one or both directions
+** TODO: document or remove block sections
+** TODO: test per-dir behavior of block sections
+** TODO: Catch-up documentation on r: methods
+** TODO: 500 errors instead of 404 with AddHandler lua-script
+** TODO: Suppress internal details (fs path to scripts, etc) in error responses

* License
Apache License, Version 2.0,

Modified: httpd/httpd/branches/2.4.x/modules/lua/lua_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/lua/lua_config.c?rev=1369494&r1=1369493&r2=1369494&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/lua/lua_config.c (original)
+++ httpd/httpd/branches/2.4.x/modules/lua/lua_config.c Sat Aug 4 22:21:56 2012
@@ -154,14 +154,6 @@ static const struct luaL_Reg cfg_methods
{NULL, NULL}
};

-
-static int cmd_foo(lua_State *L)
-{
- cmd_parms *cmd = check_cmd_parms(L, 1);
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, cmd->server, APLOGNO(01479) "FOO!");
- return 0;
-}
-
/* helper function for the logging functions below */
static int cmd_log_at(lua_State *L, int level)
{
@@ -181,88 +173,70 @@ static int cmd_log_at(lua_State *L, int
/* r:debug(String) and friends which use apache logging */
static int cmd_emerg(lua_State *L)
{
- cmd_log_at(L, APLOG_EMERG);
- return 0;
+ return cmd_log_at(L, APLOG_EMERG);
}
static int cmd_alert(lua_State *L)
{
- cmd_log_at(L, APLOG_ALERT);
- return 0;
+ return cmd_log_at(L, APLOG_ALERT);
}
static int cmd_crit(lua_State *L)
{
- cmd_log_at(L, APLOG_CRIT);
- return 0;
+ return cmd_log_at(L, APLOG_CRIT);
}
static int cmd_err(lua_State *L)
{
- cmd_log_at(L, APLOG_ERR);
- return 0;
+ return cmd_log_at(L, APLOG_ERR);
}
static int cmd_warn(lua_State *L)
{
- cmd_log_at(L, APLOG_WARNING);
- return 0;
+ return cmd_log_at(L, APLOG_WARNING);
}
static int cmd_notice(lua_State *L)
{
- cmd_log_at(L, APLOG_NOTICE);
- return 0;
+ return cmd_log_at(L, APLOG_NOTICE);
}
static int cmd_info(lua_State *L)
{
- cmd_log_at(L, APLOG_INFO);
- return 0;
+ return cmd_log_at(L, APLOG_INFO);
}
static int cmd_debug(lua_State *L)
{
- cmd_log_at(L, APLOG_DEBUG);
- return 0;
+ return cmd_log_at(L, APLOG_DEBUG);
}
static int cmd_trace1(lua_State *L)
{
- cmd_log_at(L, APLOG_TRACE1);
- return 0;
+ return cmd_log_at(L, APLOG_TRACE1);
}
static int cmd_trace2(lua_State *L)
{
- cmd_log_at(L, APLOG_TRACE2);
- return 0;
+ return cmd_log_at(L, APLOG_TRACE2);
}
static int cmd_trace3(lua_State *L)
{
- cmd_log_at(L, APLOG_TRACE3);
- return 0;
+ return cmd_log_at(L, APLOG_TRACE3);
}
static int cmd_trace4(lua_State *L)
{
- cmd_log_at(L, APLOG_TRACE4);
- return 0;
+ return cmd_log_at(L, APLOG_TRACE4);
}
static int cmd_trace5(lua_State *L)
{
- cmd_log_at(L, APLOG_TRACE5);
- return 0;
+ return cmd_log_at(L, APLOG_TRACE5);
}
static int cmd_trace6(lua_State *L)
{
- cmd_log_at(L, APLOG_TRACE6);
- return 0;
+ return cmd_log_at(L, APLOG_TRACE6);
}
static int cmd_trace7(lua_State *L)
{
- cmd_log_at(L, APLOG_TRACE7);
- return 0;
+ return cmd_log_at(L, APLOG_TRACE7);
}
static int cmd_trace8(lua_State *L)
{
- cmd_log_at(L, APLOG_TRACE8);
- return 0;
+ return cmd_log_at(L, APLOG_TRACE8);
}

static const struct luaL_Reg cmd_methods[] = {
- {"foo", cmd_foo},
-
{"trace8", cmd_trace8},
{"trace7", cmd_trace7},
{"trace6", cmd_trace6},

Modified: httpd/httpd/branches/2.4.x/modules/lua/lua_request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/lua/lua_request.c?rev=1369494&r1=1369493&r2=1369494&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/lua/lua_request.c (original)
+++ httpd/httpd/branches/2.4.x/modules/lua/lua_request.c Sat Aug 4 22:21:56 2012
@@ -263,6 +263,16 @@ static const char *req_document_root(req
return ap_document_root(r);
}

+static const char *req_context_prefix(request_rec *r)
+{
+ return ap_context_prefix(r);
+}
+
+static const char *req_context_document_root(request_rec *r)
+{
+ return ap_context_document_root(r);
+}
+
static char *req_uri_field(request_rec *r)
{
return r->uri;
@@ -351,6 +361,16 @@ static const char *req_the_request_field
return r->the_request;
}

+static const char *req_log_id_field(request_rec *r)
+{
+ return r->log_id;
+}
+
+static const char *req_useragent_ip_field(request_rec *r)
+{
+ return r->useragent_ip;
+}
+
static int req_status_field(request_rec *r)
{
return r->status;
@@ -480,49 +500,40 @@ static int req_log_at(lua_State *L, int
/* r:debug(String) and friends which use apache logging */
static int req_emerg(lua_State *L)
{
- req_log_at(L, APLOG_EMERG);
- return 0;
+ return req_log_at(L, APLOG_EMERG);
}
static int req_alert(lua_State *L)
{
- req_log_at(L, APLOG_ALERT);
- return 0;
+ return req_log_at(L, APLOG_ALERT);
}
static int req_crit(lua_State *L)
{
- req_log_at(L, APLOG_CRIT);
- return 0;
+ return req_log_at(L, APLOG_CRIT);
}
static int req_err(lua_State *L)
{
- req_log_at(L, APLOG_ERR);
- return 0;
+ return req_log_at(L, APLOG_ERR);
}
static int req_warn(lua_State *L)
{
- req_log_at(L, APLOG_WARNING);
- return 0;
+ return req_log_at(L, APLOG_WARNING);
}
static int req_notice(lua_State *L)
{
- req_log_at(L, APLOG_NOTICE);
- return 0;
+ return req_log_at(L, APLOG_NOTICE);
}
static int req_info(lua_State *L)
{
- req_log_at(L, APLOG_INFO);
- return 0;
+ return req_log_at(L, APLOG_INFO);
}
static int req_debug(lua_State *L)
{
- req_log_at(L, APLOG_DEBUG);
- return 0;
+ return req_log_at(L, APLOG_DEBUG);
}

#define APLUA_REQ_TRACE(lev) static int req_trace##lev(lua_State *L) \
{ \
- req_log_at(L, APLOG_TRACE##lev); \
- return 0; \
+ return req_log_at(L, APLOG_TRACE##lev); \
}

APLUA_REQ_TRACE(1)
@@ -636,6 +647,10 @@ AP_LUA_DECLARE(void) ap_lua_load_request
makefun(&req_write, APL_REQ_FUNTYPE_LUACFUN, p));
apr_hash_set(dispatch, "document_root", APR_HASH_KEY_STRING,
makefun(&req_document_root, APL_REQ_FUNTYPE_STRING, p));
+ apr_hash_set(dispatch, "context_prefix", APR_HASH_KEY_STRING,
+ makefun(&req_context_prefix, APL_REQ_FUNTYPE_STRING, p));
+ apr_hash_set(dispatch, "context_document_root", APR_HASH_KEY_STRING,
+ makefun(&req_context_document_root, APL_REQ_FUNTYPE_STRING, p));
apr_hash_set(dispatch, "parseargs", APR_HASH_KEY_STRING,
makefun(&req_parseargs, APL_REQ_FUNTYPE_LUACFUN, p));
apr_hash_set(dispatch, "parsebody", APR_HASH_KEY_STRING,
@@ -718,6 +733,10 @@ AP_LUA_DECLARE(void) ap_lua_load_request
makefun(&req_uri_field, APL_REQ_FUNTYPE_STRING, p));
apr_hash_set(dispatch, "the_request", APR_HASH_KEY_STRING,
makefun(&req_the_request_field, APL_REQ_FUNTYPE_STRING, p));
+ apr_hash_set(dispatch, "log_id", APR_HASH_KEY_STRING,
+ makefun(&req_log_id_field, APL_REQ_FUNTYPE_STRING, p));
+ apr_hash_set(dispatch, "useragent_ip", APR_HASH_KEY_STRING,
+ makefun(&req_useragent_ip_field, APL_REQ_FUNTYPE_STRING, p));
apr_hash_set(dispatch, "method", APR_HASH_KEY_STRING,
makefun(&req_method_field, APL_REQ_FUNTYPE_STRING, p));
apr_hash_set(dispatch, "proxyreq", APR_HASH_KEY_STRING,
@@ -774,7 +793,7 @@ AP_LUA_DECLARE(void) ap_lua_push_connect
lua_setfield(L, -2, "notes");

lua_pushstring(L, c->client_ip);
- lua_setfield(L, -2, "remote_ip");
+ lua_setfield(L, -2, "client_ip");

lua_pop(L, 1);
}

Modified: httpd/httpd/branches/2.4.x/modules/lua/lua_vmprep.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/lua/lua_vmprep.c?rev=1369494&r1=1369493&r2=1369494&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/lua/lua_vmprep.c (original)
+++ httpd/httpd/branches/2.4.x/modules/lua/lua_vmprep.c Sat Aug 4 22:21:56 2012
@@ -96,6 +96,8 @@ static void pstack_dump(lua_State *L, ap

/* BEGIN apache lmodule */

+#define makeintegerfield(L, n) lua_pushinteger(L, n); lua_setfield(L, -2, #n)
+
AP_LUA_DECLARE(void) ap_lua_load_apache2_lmodule(lua_State *L)
{
lua_getglobal(L, "package");
@@ -106,148 +108,78 @@ AP_LUA_DECLARE(void) ap_lua_load_apache2
lua_pop(L, 1); /* empty stack */

lua_getglobal(L, "apache2");
- lua_pushinteger(L, OK);
- lua_setfield(L, -2, "OK");
-
- lua_pushinteger(L, DECLINED);
- lua_setfield(L, -2, "DECLINED");
-
- lua_pushinteger(L, DONE);
- lua_setfield(L, -2, "DONE");

lua_pushstring(L, ap_get_server_banner());
lua_setfield(L, -2, "version");

- lua_pushinteger(L, HTTP_MOVED_TEMPORARILY);
- lua_setfield(L, -2, "HTTP_MOVED_TEMPORARILY");
-
- lua_pushinteger(L, PROXYREQ_NONE);
- lua_setfield(L, -2, "PROXYREQ_NONE");
-
- lua_pushinteger(L, PROXYREQ_PROXY);
- lua_setfield(L, -2, "PROXYREQ_PROXY");
-
- lua_pushinteger(L, PROXYREQ_REVERSE);
- lua_setfield(L, -2, "PROXYREQ_REVERSE");
-
- lua_pushinteger(L, PROXYREQ_RESPONSE);
- lua_setfield(L, -2, "PROXYREQ_RESPONSE");
+ makeintegerfield(L, OK);
+ makeintegerfield(L, DECLINED);
+ makeintegerfield(L, DONE);
+ makeintegerfield(L, HTTP_MOVED_TEMPORARILY);
+ makeintegerfield(L, PROXYREQ_NONE);
+ makeintegerfield(L, PROXYREQ_PROXY);
+ makeintegerfield(L, PROXYREQ_REVERSE);
+ makeintegerfield(L, PROXYREQ_RESPONSE);
+ makeintegerfield(L, PROXYREQ_RESPONSE);

/*
- lua_pushinteger(L, HTTP_CONTINUE);
- lua_setfield(L, -2, "HTTP_CONTINUE");
- lua_pushinteger(L, HTTP_SWITCHING_PROTOCOLS);
- lua_setfield(L, -2, "HTTP_SWITCHING_PROTOCOLS");
- lua_pushinteger(L, HTTP_PROCESSING);
- lua_setfield(L, -2, "HTTP_PROCESSING");
- lua_pushinteger(L, HTTP_OK);
- lua_setfield(L, -2, "HTTP_OK");
- lua_pushinteger(L, HTTP_CREATED);
- lua_setfield(L, -2, "HTTP_CREATED");
- lua_pushinteger(L, HTTP_ACCEPTED);
- lua_setfield(L, -2, "HTTP_ACCEPTED");
- lua_pushinteger(L, HTTP_NON_AUTHORITATIVE);
- lua_setfield(L, -2, "HTTP_NON_AUTHORITATIVE");
- lua_pushinteger(L, HTTP_NO_CONTENT);
- lua_setfield(L, -2, "HTTP_NO_CONTENT");
- lua_pushinteger(L, HTTP_RESET_CONTENT);
- lua_setfield(L, -2, "HTTP_RESET_CONTENT");
- lua_pushinteger(L, HTTP_PARTIAL_CONTENT);
- lua_setfield(L, -2, "HTTP_PARTIAL_CONTENT");
- lua_pushinteger(L, HTTP_MULTI_STATUS);
- lua_setfield(L, -2, "HTTP_MULTI_STATUS");
- lua_pushinteger(L, HTTP_ALREADY_REPORTED);
- lua_setfield(L, -2, "HTTP_ALREADY_REPORTED");
- lua_pushinteger(L, HTTP_IM_USED);
- lua_setfield(L, -2, "HTTP_IM_USED");
- lua_pushinteger(L, HTTP_MULTIPLE_CHOICES);
- lua_setfield(L, -2, "HTTP_MULTIPLE_CHOICES");
- lua_pushinteger(L, HTTP_MOVED_PERMANENTLY);
- lua_setfield(L, -2, "HTTP_MOVED_PERMANENTLY");
- lua_pushinteger(L, HTTP_MOVED_TEMPORARILY);
- lua_setfield(L, -2, "HTTP_MOVED_TEMPORARILY");
- lua_pushinteger(L, HTTP_SEE_OTHER);
- lua_setfield(L, -2, "HTTP_SEE_OTHER");
- lua_pushinteger(L, HTTP_NOT_MODIFIED);
- lua_setfield(L, -2, "HTTP_NOT_MODIFIED");
- lua_pushinteger(L, HTTP_USE_PROXY);
- lua_setfield(L, -2, "HTTP_USE_PROXY");
- lua_pushinteger(L, HTTP_TEMPORARY_REDIRECT);
- lua_setfield(L, -2, "HTTP_TEMPORARY_REDIRECT");
- lua_pushinteger(L, HTTP_PERMANENT_REDIRECT);
- lua_setfield(L, -2, "HTTP_PERMANENT_REDIRECT");
- lua_pushinteger(L, HTTP_BAD_REQUEST);
- lua_setfield(L, -2, "HTTP_BAD_REQUEST");
- lua_pushinteger(L, HTTP_UNAUTHORIZED);
- lua_setfield(L, -2, "HTTP_UNAUTHORIZED");
- lua_pushinteger(L, HTTP_PAYMENT_REQUIRED);
- lua_setfield(L, -2, "HTTP_PAYMENT_REQUIRED");
- lua_pushinteger(L, HTTP_FORBIDDEN);
- lua_setfield(L, -2, "HTTP_FORBIDDEN");
- lua_pushinteger(L, HTTP_NOT_FOUND);
- lua_setfield(L, -2, "HTTP_NOT_FOUND");
- lua_pushinteger(L, HTTP_METHOD_NOT_ALLOWED);
- lua_setfield(L, -2, "HTTP_METHOD_NOT_ALLOWED");
- lua_pushinteger(L, HTTP_NOT_ACCEPTABLE);
- lua_setfield(L, -2, "HTTP_NOT_ACCEPTABLE");
- lua_pushinteger(L, HTTP_PROXY_AUTHENTICATION_REQUIRED);
- lua_setfield(L, -2, "HTTP_PROXY_AUTHENTICATION_REQUIRED");
- lua_pushinteger(L, HTTP_REQUEST_TIME_OUT);
- lua_setfield(L, -2, "HTTP_REQUEST_TIME_OUT");
- lua_pushinteger(L, HTTP_CONFLICT);
- lua_setfield(L, -2, "HTTP_CONFLICT");
- lua_pushinteger(L, HTTP_GONE);
- lua_setfield(L, -2, "HTTP_GONE");
- lua_pushinteger(L, HTTP_LENGTH_REQUIRED);
- lua_setfield(L, -2, "HTTP_LENGTH_REQUIRED");
- lua_pushinteger(L, HTTP_PRECONDITION_FAILED);
- lua_setfield(L, -2, "HTTP_PRECONDITION_FAILED");
- lua_pushinteger(L, HTTP_REQUEST_ENTITY_TOO_LARGE);
- lua_setfield(L, -2, "HTTP_REQUEST_ENTITY_TOO_LARGE");
- lua_pushinteger(L, HTTP_REQUEST_URI_TOO_LARGE);
- lua_setfield(L, -2, "HTTP_REQUEST_URI_TOO_LARGE");
- lua_pushinteger(L, HTTP_UNSUPPORTED_MEDIA_TYPE);
- lua_setfield(L, -2, "HTTP_UNSUPPORTED_MEDIA_TYPE");
- lua_pushinteger(L, HTTP_RANGE_NOT_SATISFIABLE);
- lua_setfield(L, -2, "HTTP_RANGE_NOT_SATISFIABLE");
- lua_pushinteger(L, HTTP_EXPECTATION_FAILED);
- lua_setfield(L, -2, "HTTP_EXPECTATION_FAILED");
- lua_pushinteger(L, HTTP_UNPROCESSABLE_ENTITY);
- lua_setfield(L, -2, "HTTP_UNPROCESSABLE_ENTITY");
- lua_pushinteger(L, HTTP_LOCKED);
- lua_setfield(L, -2, "HTTP_LOCKED");
- lua_pushinteger(L, HTTP_FAILED_DEPENDENCY);
- lua_setfield(L, -2, "HTTP_FAILED_DEPENDENCY");
- lua_pushinteger(L, HTTP_UPGRADE_REQUIRED);
- lua_setfield(L, -2, "HTTP_UPGRADE_REQUIRED");
- lua_pushinteger(L, HTTP_PRECONDITION_REQUIRED);
- lua_setfield(L, -2, "HTTP_PRECONDITION_REQUIRED");
- lua_pushinteger(L, HTTP_TOO_MANY_REQUESTS);
- lua_setfield(L, -2, "HTTP_TOO_MANY_REQUESTS");
- lua_pushinteger(L, HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE);
- lua_setfield(L, -2, "HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE");
- lua_pushinteger(L, HTTP_INTERNAL_SERVER_ERROR);
- lua_setfield(L, -2, "HTTP_INTERNAL_SERVER_ERROR");
- lua_pushinteger(L, HTTP_NOT_IMPLEMENTED);
- lua_setfield(L, -2, "HTTP_NOT_IMPLEMENTED");
- lua_pushinteger(L, HTTP_BAD_GATEWAY);
- lua_setfield(L, -2, "HTTP_BAD_GATEWAY");
- lua_pushinteger(L, HTTP_SERVICE_UNAVAILABLE);
- lua_setfield(L, -2, "HTTP_SERVICE_UNAVAILABLE");
- lua_pushinteger(L, HTTP_GATEWAY_TIME_OUT);
- lua_setfield(L, -2, "HTTP_GATEWAY_TIME_OUT");
- lua_pushinteger(L, HTTP_VERSION_NOT_SUPPORTED);
- lua_setfield(L, -2, "HTTP_VERSION_NOT_SUPPORTED");
- lua_pushinteger(L, HTTP_VARIANT_ALSO_VARIES);
- lua_setfield(L, -2, "HTTP_VARIANT_ALSO_VARIES");
- lua_pushinteger(L, HTTP_INSUFFICIENT_STORAGE);
- lua_setfield(L, -2, "HTTP_INSUFFICIENT_STORAGE");
- lua_pushinteger(L, HTTP_LOOP_DETECTED);
- lua_setfield(L, -2, "HTTP_LOOP_DETECTED");
- lua_pushinteger(L, HTTP_NOT_EXTENDED);
- lua_setfield(L, -2, "HTTP_NOT_EXTENDED");
- lua_pushinteger(L, HTTP_NETWORK_AUTHENTICATION_REQUIRED);
- lua_setfield(L, -2, "HTTP_NETWORK_AUTHENTICATION_REQUIRED");
+ makeintegerfield(L, HTTP_CONTINUE);
+ makeintegerfield(L, HTTP_SWITCHING_PROTOCOLS);
+ makeintegerfield(L, HTTP_PROCESSING);
+ makeintegerfield(L, HTTP_OK);
+ makeintegerfield(L, HTTP_CREATED);
+ makeintegerfield(L, HTTP_ACCEPTED);
+ makeintegerfield(L, HTTP_NON_AUTHORITATIVE);
+ makeintegerfield(L, HTTP_NO_CONTENT);
+ makeintegerfield(L, HTTP_RESET_CONTENT);
+ makeintegerfield(L, HTTP_PARTIAL_CONTENT);
+ makeintegerfield(L, HTTP_MULTI_STATUS);
+ makeintegerfield(L, HTTP_ALREADY_REPORTED);
+ makeintegerfield(L, HTTP_IM_USED);
+ makeintegerfield(L, HTTP_MULTIPLE_CHOICES);
+ makeintegerfield(L, HTTP_MOVED_PERMANENTLY);
+ makeintegerfield(L, HTTP_MOVED_TEMPORARILY);
+ makeintegerfield(L, HTTP_SEE_OTHER);
+ makeintegerfield(L, HTTP_NOT_MODIFIED);
+ makeintegerfield(L, HTTP_USE_PROXY);
+ makeintegerfield(L, HTTP_TEMPORARY_REDIRECT);
+ makeintegerfield(L, HTTP_PERMANENT_REDIRECT);
+ makeintegerfield(L, HTTP_BAD_REQUEST);
+ makeintegerfield(L, HTTP_UNAUTHORIZED);
+ makeintegerfield(L, HTTP_PAYMENT_REQUIRED);
+ makeintegerfield(L, HTTP_FORBIDDEN);
+ makeintegerfield(L, HTTP_NOT_FOUND);
+ makeintegerfield(L, HTTP_METHOD_NOT_ALLOWED);
+ makeintegerfield(L, HTTP_NOT_ACCEPTABLE);
+ makeintegerfield(L, HTTP_PROXY_AUTHENTICATION_REQUIRED);
+ makeintegerfield(L, HTTP_REQUEST_TIME_OUT);
+ makeintegerfield(L, HTTP_CONFLICT);
+ makeintegerfield(L, HTTP_GONE);
+ makeintegerfield(L, HTTP_LENGTH_REQUIRED);
+ makeintegerfield(L, HTTP_PRECONDITION_FAILED);
+ makeintegerfield(L, HTTP_REQUEST_ENTITY_TOO_LARGE);
+ makeintegerfield(L, HTTP_REQUEST_URI_TOO_LARGE);
+ makeintegerfield(L, HTTP_UNSUPPORTED_MEDIA_TYPE);
+ makeintegerfield(L, HTTP_RANGE_NOT_SATISFIABLE);
+ makeintegerfield(L, HTTP_EXPECTATION_FAILED);
+ makeintegerfield(L, HTTP_UNPROCESSABLE_ENTITY);
+ makeintegerfield(L, HTTP_LOCKED);
+ makeintegerfield(L, HTTP_FAILED_DEPENDENCY);
+ makeintegerfield(L, HTTP_UPGRADE_REQUIRED);
+ makeintegerfield(L, HTTP_PRECONDITION_REQUIRED);
+ makeintegerfield(L, HTTP_TOO_MANY_REQUESTS);
+ makeintegerfield(L, HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE);
+ makeintegerfield(L, HTTP_INTERNAL_SERVER_ERROR);
+ makeintegerfield(L, HTTP_NOT_IMPLEMENTED);
+ makeintegerfield(L, HTTP_BAD_GATEWAY);
+ makeintegerfield(L, HTTP_SERVICE_UNAVAILABLE);
+ makeintegerfield(L, HTTP_GATEWAY_TIME_OUT);
+ makeintegerfield(L, HTTP_VERSION_NOT_SUPPORTED);
+ makeintegerfield(L, HTTP_VARIANT_ALSO_VARIES);
+ makeintegerfield(L, HTTP_INSUFFICIENT_STORAGE);
+ makeintegerfield(L, HTTP_LOOP_DETECTED);
+ makeintegerfield(L, HTTP_NOT_EXTENDED);
+ makeintegerfield(L, HTTP_NETWORK_AUTHENTICATION_REQUIRED);
*/
}

@@ -258,6 +190,7 @@ AP_LUA_DECLARE(void) ap_lua_load_apache2
/* callback for cleaning up a lua vm when pool is closed */
static apr_status_t cleanup_lua(void *l)
{
+ AP_DEBUG_ASSERT(l != NULL);
lua_close((lua_State *) l);
return APR_SUCCESS;
}
@@ -337,7 +270,7 @@ static int loadjitmodule(lua_State *L, a

#endif

-static apr_status_t vm_construct(void **vm, void *params, apr_pool_t *lifecycle_pool)
+static apr_status_t vm_construct(lua_State **vm, void *params, apr_pool_t *lifecycle_pool)
{
lua_State* L;

@@ -411,7 +344,8 @@ AP_LUA_DECLARE(lua_State*)ap_lua_get_lua
"creating lua_State with file %s", spec->file);
/* not available, so create */

- if(!vm_construct((void **)&L, spec, lifecycle_pool)) {
+ if(!vm_construct(&L, spec, lifecycle_pool)) {
+ AP_DEBUG_ASSERT(L != NULL);
apr_pool_userdata_set(L,
spec->file,
cleanup_lua,

Modified: httpd/httpd/branches/2.4.x/modules/lua/lua_vmprep.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/lua/lua_vmprep.h?rev=1369494&r1=1369493&r2=1369494&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/lua/lua_vmprep.h (original)
+++ httpd/httpd/branches/2.4.x/modules/lua/lua_vmprep.h Sat Aug 4 22:21:56 2012
@@ -54,7 +54,7 @@ typedef struct
apr_array_header_t *package_cpaths;

/* name of base file to load in the vm */
- char *file;
+ const char *file;

/* APL_SCOPE_ONCE | APL_SCOPE_REQUEST | APL_SCOPE_CONN | APL_SCOPE_THREAD */
int scope;
@@ -75,8 +75,8 @@ typedef struct

typedef struct
{
- char *function_name;
- char *file_name;
+ const char *function_name;
+ const char *file_name;
int scope;
ap_regex_t *uri_pattern;
const char *bytecode;

Modified: httpd/httpd/branches/2.4.x/modules/lua/mod_lua.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/lua/mod_lua.c?rev=1369494&r1=1369493&r2=1369494&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/lua/mod_lua.c (original)
+++ httpd/httpd/branches/2.4.x/modules/lua/mod_lua.c Sat Aug 4 22:21:56 2012
@@ -78,73 +78,114 @@ static int lua_open_hook(lua_State *L, a
return OK;
}

+static const char *scope_to_string(unsigned int scope)
+{
+ switch (scope) {
+ case AP_LUA_SCOPE_ONCE:
+ case AP_LUA_SCOPE_UNSET:
+ return "once";
+ case AP_LUA_SCOPE_REQUEST:
+ return "request";
+ case AP_LUA_SCOPE_CONN:
+ return "conn";
+#if APR_HAS_THREADS
+ case AP_LUA_SCOPE_THREAD:
+ return "thread";
+#endif
+ default:
+ ap_assert(0);
+ }
+}
+
+static ap_lua_vm_spec *create_vm_spec(apr_pool_t **lifecycle_pool,
+ request_rec *r,
+ const ap_lua_dir_cfg *cfg,
+ const ap_lua_server_cfg *server_cfg,
+ const char *filename,
+ const char *bytecode,
+ apr_size_t bytecode_len,
+ const char *function,
+ const char *what)
+{
+ apr_pool_t *pool;
+ ap_lua_vm_spec *spec = apr_pcalloc(r->pool, sizeof(ap_lua_vm_spec));
+
+ spec->scope = cfg->vm_scope;
+ spec->pool = r->pool;
+ spec->package_paths = cfg->package_paths;
+ spec->package_cpaths = cfg->package_cpaths;
+ spec->cb = &lua_open_callback;
+ spec->cb_arg = NULL;
+ spec->bytecode = bytecode;
+ spec->bytecode_len = bytecode_len;
+
+ if (filename) {
+ char *file;
+ apr_filepath_merge(&file, server_cfg->root_path,
+ filename, APR_FILEPATH_NOTRELATIVE, r->pool);
+ spec->file = file;
+ }
+ else {
+ spec->file = r->filename;
+ }
+ ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, APLOGNO()
+ "%s details: scope: %s, file: %s, func: %s",
+ what, scope_to_string(spec->scope), spec->file,
+ function ? function : "-");
+
+ switch (spec->scope) {
+ case AP_LUA_SCOPE_ONCE:
+ case AP_LUA_SCOPE_UNSET:
+ apr_pool_create(&pool, r->pool);
+ break;
+ case AP_LUA_SCOPE_REQUEST:
+ pool = r->pool;
+ break;
+ case AP_LUA_SCOPE_CONN:
+ pool = r->connection->pool;
+ break;
+#if APR_HAS_THREADS
+ case AP_LUA_SCOPE_THREAD:
+ pool = apr_thread_pool_get(r->connection->current_thread);
+ break;
+#endif
+ default:
+ ap_assert(0);
+ }
+
+ *lifecycle_pool = pool;
+ return spec;
+}
+

/**
* "main"
*/
static int lua_handler(request_rec *r)
{
- ap_lua_dir_cfg *dcfg;
- apr_pool_t *pool;
if (strcmp(r->handler, "lua-script")) {
return DECLINED;
}
-
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01472) "handling [%s] in mod_lua",
- r->filename);
- dcfg = ap_get_module_config(r->per_dir_config, &lua_module);
+ ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, APLOGNO(01472)
+ "handling [%s] in mod_lua", r->filename);

+ /* XXX: This seems wrong because it may generate wrong headers for HEAD requests */
if (!r->header_only) {
lua_State *L;
+ apr_pool_t *pool;
const ap_lua_dir_cfg *cfg = ap_get_module_config(r->per_dir_config,
&lua_module);
- ap_lua_vm_spec *spec = NULL;
+ ap_lua_vm_spec *spec = create_vm_spec(&pool, r, cfg, NULL, NULL, NULL,
+ 0, "handle", "request handler");

- spec = apr_pcalloc(r->pool, sizeof(ap_lua_vm_spec));
- spec->scope = dcfg->vm_scope;
- spec->pool = r->pool;
- spec->file = r->filename;
- spec->package_paths = cfg->package_paths;
- spec->package_cpaths = cfg->package_cpaths;
- spec->cb = &lua_open_callback;
- spec->cb_arg = NULL;
-
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01473)
- "request details scope:%u, filename:%s, function:%s",
- spec->scope,
- spec->file,
- "handle");
-
- switch (spec->scope) {
- case AP_LUA_SCOPE_ONCE:
- case AP_LUA_SCOPE_UNSET:
- apr_pool_create(&pool, r->pool);
- break;
- case AP_LUA_SCOPE_REQUEST:
- pool = r->pool;
- break;
- case AP_LUA_SCOPE_CONN:
- pool = r->connection->pool;
- break;
- case AP_LUA_SCOPE_THREAD:
- #if APR_HAS_THREADS
- pool = apr_thread_pool_get(r->connection->current_thread);
- break;
- #endif
- default:
- ap_assert(0);
- }
-
- L = ap_lua_get_lua_state(pool,
- spec);
-
+ L = ap_lua_get_lua_state(pool, spec);
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, APLOGNO(01474) "got a vm!");
+ ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r, APLOGNO(01474) "got a vm!");
lua_getglobal(L, "handle");
if (!lua_isfunction(L, -1)) {
ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r, APLOGNO(01475)
@@ -163,7 +204,6 @@ static int lua_handler(request_rec *r)



-
/* ---------------- Configury stuff --------------- */

/** harnesses for magic hooks **/
@@ -190,46 +230,12 @@ static int lua_request_rec_hook_harness(
if (hook_spec == NULL) {
continue;
}
- spec = apr_pcalloc(r->pool, sizeof(ap_lua_vm_spec));
-
- spec->file = hook_spec->file_name;
- spec->scope = cfg->vm_scope;
- spec->bytecode = hook_spec->bytecode;
- spec->bytecode_len = hook_spec->bytecode_len;
- spec->pool = r->pool;
- spec->package_paths = cfg->package_paths;
- spec->package_cpaths = cfg->package_cpaths;
- spec->cb = &lua_open_callback;
- spec->cb_arg = NULL;
-
- apr_filepath_merge(&spec->file, server_cfg->root_path,
- spec->file, APR_FILEPATH_NOTRELATIVE, r->pool);
-
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01476)
- "request details scope:%u, filename:%s, function:%s",
- spec->scope,
- spec->file,
- hook_spec->function_name ? hook_spec->function_name : "-");
-
- switch (spec->scope) {
- case AP_LUA_SCOPE_ONCE:
- case AP_LUA_SCOPE_UNSET:
- apr_pool_create(&pool, r->pool);
- break;
- case AP_LUA_SCOPE_REQUEST:
- pool = r->pool;
- break;
- case AP_LUA_SCOPE_CONN:
- pool = r->connection->pool;
- break;
- case AP_LUA_SCOPE_THREAD:
- #if APR_HAS_THREADS
- pool = apr_thread_pool_get(r->connection->current_thread);
- break;
- #endif
- default:
- ap_assert(0);
- }
+ spec = create_vm_spec(&pool, r, cfg, server_cfg,
+ hook_spec->file_name,
+ hook_spec->bytecode,
+ hook_spec->bytecode_len,
+ hook_spec->function_name,
+ "request hook");

L = ap_lua_get_lua_state(pool, spec);


Modified: httpd/httpd/branches/2.4.x/modules/lua/mod_lua.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/lua/mod_lua.h?rev=1369494&r1=1369493&r2=1369494&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/lua/mod_lua.h (original)
+++ httpd/httpd/branches/2.4.x/modules/lua/mod_lua.h Sat Aug 4 22:21:56 2012
@@ -116,7 +116,7 @@ typedef struct
apr_hash_t *hooks; /* <wombat_hook_info> */

/* the actual directory being configured */
- char *dir;
+ const char *dir;

/* Whether Lua scripts in a sub-dir are run before parents */
ap_lua_inherit_t inherit;
@@ -134,7 +134,7 @@ typedef struct

typedef struct
{
- char *function_name;
+ const char *function_name;
ap_lua_vm_spec *spec;
} mapped_request_details;

@@ -147,7 +147,7 @@ typedef struct
typedef struct
{
lua_State *L;
- char *function;
+ const char *function;
} ap_lua_filter_ctx;

extern module AP_MODULE_DECLARE_DATA lua_module;

Apache cvs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.