httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r709988 - in /httpd/mod_wombat/trunk: README request.c test/test.lua
Date Sun, 02 Nov 2008 23:11:43 GMT
Author: brianm
Date: Sun Nov  2 15:11:43 2008
New Revision: 709988

URL: http://svn.apache.org/viewvc?rev=709988&view=rev
Log:
add r:document_root() to allow querying the document root

Modified:
    httpd/mod_wombat/trunk/README
    httpd/mod_wombat/trunk/request.c
    httpd/mod_wombat/trunk/test/test.lua

Modified: httpd/mod_wombat/trunk/README
URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/README?rev=709988&r1=709987&r2=709988&view=diff
==============================================================================
--- httpd/mod_wombat/trunk/README (original)
+++ httpd/mod_wombat/trunk/README Sun Nov  2 15:11:43 2008
@@ -24,7 +24,16 @@
   associated with a thread? Contention on the pool is a pain in a
   highly concurrent environment.
 
-  
+  Could use apr_thread_data_(get|set) if I can find a way to hook into
+  thread destruction. Looks like apr threads let you use the standard
+  APR_POOL_DECLARE_ACCESSOR(thread); defined method, just need to look
+  up what form that takes. 
+
+  Given that, we can associate a hash of lua_State instances with
+  arbitrary pools, such as the request pool, thread pool, server pool,
+  etc. We then use the file as key into the hash. Users, able to
+  specify the handler function, can then make use of the same file
+  with different handlers to reuse states.
 
 * Task List
 ** TODO Use r->file to determine file, doing rewriting in translate_name   

Modified: httpd/mod_wombat/trunk/request.c
URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/request.c?rev=709988&r1=709987&r2=709988&view=diff
==============================================================================
--- httpd/mod_wombat/trunk/request.c (original)
+++ httpd/mod_wombat/trunk/request.c Sun Nov  2 15:11:43 2008
@@ -186,6 +186,13 @@
     return 0;
 }
 
+static int req_document_root(lua_State* L) {
+  request_rec* r = check_request_rec(L, 1);
+  char* doc_root = apr_pstrdup(r->pool, ap_document_root(r));
+  lua_pushstring(L, doc_root);
+  return 1;
+}
+
 // helper function for the logging functions below
 static int req_log_at(lua_State* L, int level) {
     request_rec* r = check_request_rec(L, 1);
@@ -262,6 +269,7 @@
 static const struct luaL_Reg request_methods[] = {
     {"puts", req_puts},
     {"write", req_write},
+    {"document_root", req_document_root},
     {"parseargs", req_parseargs},
     {"parsebody", req_parsebody},
     

Modified: httpd/mod_wombat/trunk/test/test.lua
URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/test/test.lua?rev=709988&r1=709987&r2=709988&view=diff
==============================================================================
--- httpd/mod_wombat/trunk/test/test.lua (original)
+++ httpd/mod_wombat/trunk/test/test.lua Sun Nov  2 15:11:43 2008
@@ -21,6 +21,13 @@
 http.base_url = "http://localhost:8000"
 
 local test = mu.TestCase:new{}
+
+function test:document_root()
+  local b, c = http.get "/document_root.lua"
+  assert(200 == c, "expected status code 200, got " .. c)
+  assert(b:find("test"), "test not found in document root")
+end
+
 function test:basic_get()
   local b, c = http.get "/basic"
   assert(200 == c, "expected status code 200, got " .. c)



Mime
View raw message