Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 1307 invoked from network); 6 Nov 2008 16:31:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Nov 2008 16:31:36 -0000 Received: (qmail 2888 invoked by uid 500); 6 Nov 2008 16:31:42 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 2831 invoked by uid 500); 6 Nov 2008 16:31:42 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 2822 invoked by uid 99); 6 Nov 2008 16:31:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Nov 2008 08:31:42 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Nov 2008 16:30:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 276D62388961; Thu, 6 Nov 2008 08:31:15 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r711897 - in /httpd/mod_wombat/trunk: README vmprep.c vmprep.h Date: Thu, 06 Nov 2008 16:31:08 -0000 To: cvs@httpd.apache.org From: brianm@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081106163115.276D62388961@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: brianm Date: Thu Nov 6 08:30:53 2008 New Revision: 711897 URL: http://svn.apache.org/viewvc?rev=711897&view=rev Log: starting work on better lifecycle management Modified: httpd/mod_wombat/trunk/README httpd/mod_wombat/trunk/vmprep.c httpd/mod_wombat/trunk/vmprep.h Modified: httpd/mod_wombat/trunk/README URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/README?rev=711897&r1=711896&r2=711897&view=diff ============================================================================== --- httpd/mod_wombat/trunk/README (original) +++ httpd/mod_wombat/trunk/README Thu Nov 6 08:30:53 2008 @@ -4,7 +4,6 @@ ** libapreq2 ( http://httpd.apache.org/apreq/download.cgi ) ** Apache HTTPD 2.2 ( http://httpd.apache.org/ ) - * Documentation See docs/README @@ -27,7 +26,8 @@ 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. + up what form that takes. -- apr_thread_pool_get -- just attach to + that pool. Given that, we can associate a hash of lua_State instances with arbitrary pools, such as the request pool, thread pool, server pool, @@ -35,7 +35,7 @@ specify the handler function, can then make use of the same file with different handlers to reuse states. - Review Blue PiL 265-267 for cleaning up UserData stuff. + * Task List ** TODO Use r->file to determine file, doing rewriting in translate_name Modified: httpd/mod_wombat/trunk/vmprep.c URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/vmprep.c?rev=711897&r1=711896&r2=711897&view=diff ============================================================================== --- httpd/mod_wombat/trunk/vmprep.c (original) +++ httpd/mod_wombat/trunk/vmprep.c Thu Nov 6 08:30:53 2008 @@ -655,6 +655,26 @@ return lua_pcall(L, 0, LUA_MULTRET, 0); } +lua_State* apw_get_lua_state(apr_pool_t* lifecycle_pool, char* file) { + + lua_State* L; + if (!apr_pool_userdata_get((void**)&L, file, lifecycle_pool)) { + // not available, so create + L = luaL_newstate(); + luaL_openlibs(L); + apw_run_wombat_open(L, lifecycle_pool); + + // munge_path(L, "path", "?.lua", "./?.lua", pool, spec->package_paths, spec->file); + // munge_path(L, "cpath", "?.so", "./?.so", pool, spec->package_cpaths, spec->file); + luaL_loadfile(L, file); + lua_pcall(L, 0, LUA_MULTRET, 0); + apr_pool_userdata_set(L, file, &cleanup_lua, lifecycle_pool); + + lua_pushlightuserdata(L, lifecycle_pool); + lua_setfield(L, LUA_REGISTRYINDEX, "Apache2.Wombat.pool"); + } + return L; +} Modified: httpd/mod_wombat/trunk/vmprep.h URL: http://svn.apache.org/viewvc/httpd/mod_wombat/trunk/vmprep.h?rev=711897&r1=711896&r2=711897&view=diff ============================================================================== --- httpd/mod_wombat/trunk/vmprep.h (original) +++ httpd/mod_wombat/trunk/vmprep.h Thu Nov 6 08:30:53 2008 @@ -103,5 +103,8 @@ // returns NULL if the spec requires a request scope or conn scope lua_State* apw_sgetvm(server_rec *r, apw_vm_spec *spec); +// alternate means of getting lua_State +lua_State* apw_get_lua_state(apr_pool_t* lifecycle_pool, char* file); + #endif