lua_vmprep.c revision ec7851f543720a66e94295707116b4bc91961030
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski/**
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski * Licensed to the Apache Software Foundation (ASF) under one or more
c06dd8856a03b72f6b3f69e874f8700f10cb8522Christian Maeder * contributor license agreements. See the NOTICE file distributed with
75a6279dbae159d018ef812185416cf6df386c10Till Mossakowski * this work for additional information regarding copyright ownership.
75a6279dbae159d018ef812185416cf6df386c10Till Mossakowski * The ASF licenses this file to You under the Apache License, Version 2.0
c06dd8856a03b72f6b3f69e874f8700f10cb8522Christian Maeder * (the "License"); you may not use this file except in compliance with
ae17d457c2d00d47d65e8cd510c3fd21b9516ccbTill Mossakowski * the License. You may obtain a copy of the License at
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski *
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski * http://www.apache.org/licenses/LICENSE-2.0
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder *
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder * Unless required by applicable law or agreed to in writing, software
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder * distributed under the License is distributed on an "AS IS" BASIS,
679d3f541f7a9ede4079e045f7758873bb901872Till Mossakowski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
679d3f541f7a9ede4079e045f7758873bb901872Till Mossakowski * See the License for the specific language governing permissions and
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski * limitations under the License.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder */
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski#include "mod_lua.h"
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder#include "http_log.h"
82d681fe6950e2a35f28fdefb874d060632faccaTill Mossakowski#include "apr_uuid.h"
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski#include "lua_config.h"
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski#include "apr_file_info.h"
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski
70e2af8d4bf21bcdfb53e9a0414e27173b577a1eTill MossakowskiAPLOG_USE_MODULE(lua);
70e2af8d4bf21bcdfb53e9a0414e27173b577a1eTill Mossakowski
2b4130336e941b7d01c78a6da55449a4c6eca609Till Mossakowski/* forward dec'l from this file */
2b4130336e941b7d01c78a6da55449a4c6eca609Till Mossakowski
2b4130336e941b7d01c78a6da55449a4c6eca609Till Mossakowski#if 0
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederstatic void pstack_dump(lua_State *L, apr_pool_t *r, int level,
82d681fe6950e2a35f28fdefb874d060632faccaTill Mossakowski const char *msg)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder{
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder int i;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder int top = lua_gettop(L);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ap_log_perror(APLOG_MARK, level, 0, r, "Lua Stack Dump: [%s]", msg);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder for (i = 1; i <= top; i++) {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder int t = lua_type(L, i);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder switch (t) {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case LUA_TSTRING:{
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ap_log_perror(APLOG_MARK, level, 0, r,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "%d: '%s'", i, lua_tostring(L, i));
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder break;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case LUA_TUSERDATA:{
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ap_log_perror(APLOG_MARK, level, 0, r, "%d: userdata", i);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder break;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case LUA_TLIGHTUSERDATA:{
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ap_log_perror(APLOG_MARK, level, 0, r, "%d: lightuserdata",
c529224e0ec191fbaa87261f05c34f89c17b3f3aTill Mossakowski i);
c529224e0ec191fbaa87261f05c34f89c17b3f3aTill Mossakowski break;
c529224e0ec191fbaa87261f05c34f89c17b3f3aTill Mossakowski }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case LUA_TNIL:{
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ap_log_perror(APLOG_MARK, level, 0, r, "%d: NIL", i);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder break;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case LUA_TNONE:{
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ap_log_perror(APLOG_MARK, level, 0, r, "%d: None", i);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder break;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case LUA_TBOOLEAN:{
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski ap_log_perror(APLOG_MARK, level, 0, r,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "%d: %s", i, lua_toboolean(L,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder i) ? "true" :
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski "false");
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski break;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder case LUA_TNUMBER:{
e3c9174a782e90f965a0b080c22861c3ef5af12dTill Mossakowski ap_log_perror(APLOG_MARK, level, 0, r,
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski "%d: %g", i, lua_tonumber(L, i));
8fe1a8e240ccd5f3682a936ef2fa4c22fee973bcTill Mossakowski break;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder }
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski case LUA_TTABLE:{
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski ap_log_perror(APLOG_MARK, level, 0, r, "%d: <table>", i);
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski break;
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski }
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski case LUA_TTHREAD:{
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski ap_log_perror(APLOG_MARK, level, 0, r, "%d: <thread>", i);
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski break;
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski }
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski case LUA_TFUNCTION:{
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski ap_log_perror(APLOG_MARK, level, 0, r, "%d: <function>", i);
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski break;
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski }
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski default:{
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski ap_log_perror(APLOG_MARK, level, 0, r,
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski "%d: unknown: [%s]", i, lua_typename(L, i));
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski break;
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski }
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski }
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski }
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski}
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski#endif
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski/* BEGIN modules*/
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski/* BEGIN apache lmodule */
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski
1bb1684c83317dfd1692ab53415027b67d8f2faeTill MossakowskiAP_LUA_DECLARE(void) ap_lua_load_apache2_lmodule(lua_State *L)
1bb1684c83317dfd1692ab53415027b67d8f2faeTill Mossakowski{
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_getglobal(L, "package");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_getfield(L, -1, "loaded");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_newtable(L);
16f81021a104661b1872eb5af876e7c4d22fdab5Maciek Makowski lua_setfield(L, -2, "apache2");
cf29cb0194d75de2182bfc73fa7da68e90a4a19eMaciek Makowski lua_setglobal(L, "apache2");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pop(L, 1); /* empty stack */
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski lua_getglobal(L, "apache2");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, OK);
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder lua_setfield(L, -2, "OK");
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder lua_pushinteger(L, DECLINED);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "DECLINED");
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder lua_pushinteger(L, DONE);
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder lua_setfield(L, -2, "DONE");
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder lua_pushstring(L, ap_get_server_banner());
0c2a90cbfb63865ff485c3fbe20a14589a5914beTill Mossakowski lua_setfield(L, -2, "version");
c616e681da8c052b62e14247fea522da099ac0e4Christian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_MOVED_TEMPORARILY);
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder lua_setfield(L, -2, "HTTP_MOVED_TEMPORARILY");
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_pushinteger(L, PROXYREQ_NONE);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "PROXYREQ_NONE");
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, PROXYREQ_PROXY);
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski lua_setfield(L, -2, "PROXYREQ_PROXY");
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski lua_pushinteger(L, PROXYREQ_REVERSE);
31c49f2fa23d4ac089f35145d80a224deb6ea7e4Till Mossakowski lua_setfield(L, -2, "PROXYREQ_REVERSE");
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski lua_pushinteger(L, PROXYREQ_RESPONSE);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "PROXYREQ_RESPONSE");
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder /*
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_CONTINUE);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_CONTINUE");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_SWITCHING_PROTOCOLS);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_SWITCHING_PROTOCOLS");
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_pushinteger(L, HTTP_PROCESSING);
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder lua_setfield(L, -2, "HTTP_PROCESSING");
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski lua_pushinteger(L, HTTP_OK);
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski lua_setfield(L, -2, "HTTP_OK");
31c49f2fa23d4ac089f35145d80a224deb6ea7e4Till Mossakowski lua_pushinteger(L, HTTP_CREATED);
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski lua_setfield(L, -2, "HTTP_CREATED");
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski lua_pushinteger(L, HTTP_ACCEPTED);
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski lua_setfield(L, -2, "HTTP_ACCEPTED");
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski lua_pushinteger(L, HTTP_NON_AUTHORITATIVE);
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder lua_setfield(L, -2, "HTTP_NON_AUTHORITATIVE");
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski lua_pushinteger(L, HTTP_NO_CONTENT);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_NO_CONTENT");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_RESET_CONTENT);
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski lua_setfield(L, -2, "HTTP_RESET_CONTENT");
242691238a8d1a89581751d782af87ec5d7470c0Till Mossakowski lua_pushinteger(L, HTTP_PARTIAL_CONTENT);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_PARTIAL_CONTENT");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_MULTI_STATUS);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_MULTI_STATUS");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_MULTIPLE_CHOICES);
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski lua_setfield(L, -2, "HTTP_MULTIPLE_CHOICES");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_MOVED_PERMANENTLY);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_MOVED_PERMANENTLY");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_SEE_OTHER);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_SEE_OTHER");
f534c0116096e25659ceaa57de030c497ce9345aTill Mossakowski lua_pushinteger(L, HTTP_NOT_MODIFIED);
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski lua_setfield(L, -2, "HTTP_NOT_MODIFIED");
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski lua_pushinteger(L, HTTP_USE_PROXY);
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski lua_setfield(L, -2, "HTTP_USE_PROXY");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_TEMPORARY_REDIRECT);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_TEMPORARY_REDIRECT");
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_pushinteger(L, HTTP_BAD_REQUEST);
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski lua_setfield(L, -2, "HTTP_BAD_REQUEST");
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_pushinteger(L, HTTP_UNAUTHORIZED);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_UNAUTHORIZED");
bfa9e03532243ceb487f0384d0f6a447f1ce7670Till Mossakowski lua_pushinteger(L, HTTP_PAYMENT_REQUIRED);
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski lua_setfield(L, -2, "HTTP_PAYMENT_REQUIRED");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_FORBIDDEN);
788dd403da4203e895e15892ef7fa48129617d30Till Mossakowski lua_setfield(L, -2, "HTTP_FORBIDDEN");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_NOT_FOUND);
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_setfield(L, -2, "HTTP_NOT_FOUND");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_METHOD_NOT_ALLOWED);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_METHOD_NOT_ALLOWED");
a938729e277da5c7742bb88946ab2c150416fd5dTill Mossakowski lua_pushinteger(L, HTTP_NOT_ACCEPTABLE);
242691238a8d1a89581751d782af87ec5d7470c0Till Mossakowski lua_setfield(L, -2, "HTTP_NOT_ACCEPTABLE");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_PROXY_AUTHENTICATION_REQUIRED);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_PROXY_AUTHENTICATION_REQUIRED");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_REQUEST_TIME_OUT);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_REQUEST_TIME_OUT");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_CONFLICT);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_CONFLICT");
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_pushinteger(L, HTTP_GONE);
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski lua_setfield(L, -2, "HTTP_GONE");
f534c0116096e25659ceaa57de030c497ce9345aTill Mossakowski lua_pushinteger(L, HTTP_LENGTH_REQUIRED);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_LENGTH_REQUIRED");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_PRECONDITION_FAILED);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_PRECONDITION_FAILED");
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_pushinteger(L, HTTP_REQUEST_ENTITY_TOO_LARGE);
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski lua_setfield(L, -2, "HTTP_REQUEST_ENTITY_TOO_LARGE");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_REQUEST_URI_TOO_LARGE);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_REQUEST_URI_TOO_LARGE");
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_pushinteger(L, HTTP_UNSUPPORTED_MEDIA_TYPE);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_UNSUPPORTED_MEDIA_TYPE");
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski lua_pushinteger(L, HTTP_RANGE_NOT_SATISFIABLE);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_RANGE_NOT_SATISFIABLE");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_EXPECTATION_FAILED);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_EXPECTATION_FAILED");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_UNPROCESSABLE_ENTITY);
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_setfield(L, -2, "HTTP_UNPROCESSABLE_ENTITY");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_LOCKED);
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_setfield(L, -2, "HTTP_LOCKED");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_FAILED_DEPENDENCY);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_FAILED_DEPENDENCY");
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski lua_pushinteger(L, HTTP_UPGRADE_REQUIRED);
242691238a8d1a89581751d782af87ec5d7470c0Till Mossakowski lua_setfield(L, -2, "HTTP_UPGRADE_REQUIRED");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_INTERNAL_SERVER_ERROR);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_INTERNAL_SERVER_ERROR");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_NOT_IMPLEMENTED);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_NOT_IMPLEMENTED");
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushinteger(L, HTTP_BAD_GATEWAY);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_BAD_GATEWAY");
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_pushinteger(L, HTTP_SERVICE_UNAVAILABLE);
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_setfield(L, -2, "HTTP_SERVICE_UNAVAILABLE");
f534c0116096e25659ceaa57de030c497ce9345aTill Mossakowski lua_pushinteger(L, HTTP_GATEWAY_TIME_OUT);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_setfield(L, -2, "HTTP_GATEWAY_TIME_OUT");
d08907a7832988612fbc0682b216e150d1e738d2Christian Maeder lua_pushinteger(L, HTTP_VERSION_NOT_SUPPORTED);
d08907a7832988612fbc0682b216e150d1e738d2Christian Maeder lua_setfield(L, -2, "HTTP_VERSION_NOT_SUPPORTED");
d08907a7832988612fbc0682b216e150d1e738d2Christian Maeder lua_pushinteger(L, HTTP_VARIANT_ALSO_VARIES);
d08907a7832988612fbc0682b216e150d1e738d2Christian Maeder lua_setfield(L, -2, "HTTP_VARIANT_ALSO_VARIES");
d08907a7832988612fbc0682b216e150d1e738d2Christian Maeder lua_pushinteger(L, HTTP_INSUFFICIENT_STORAGE);
d08907a7832988612fbc0682b216e150d1e738d2Christian Maeder lua_setfield(L, -2, "HTTP_INSUFFICIENT_STORAGE");
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski lua_pushinteger(L, HTTP_NOT_EXTENDED);
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski lua_setfield(L, -2, "HTTP_NOT_EXTENDED");
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski */
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski}
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski/* END apache2 lmodule */
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski
242691238a8d1a89581751d782af87ec5d7470c0Till Mossakowski/* END library functions */
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski/* callback for cleaning up a lua vm when pool is closed */
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowskistatic apr_status_t cleanup_lua(void *l)
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski{
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski AP_DEBUG_ASSERT(l != NULL);
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski lua_close((lua_State *) l);
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski return APR_SUCCESS;
f534c0116096e25659ceaa57de030c497ce9345aTill Mossakowski}
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski/*
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder munge_path(L,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "path",
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "?.lua",
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski "./?.lua",
242691238a8d1a89581751d782af87ec5d7470c0Till Mossakowski lifecycle_pool,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder spec->package_paths,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder spec->file);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder*/
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder/**
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder * field -> "path" or "cpath"
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder * sub_pat -> "?.lua"
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder * rep_pat -> "./?.lua"
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski * pool -> lifecycle pool for allocations
242691238a8d1a89581751d782af87ec5d7470c0Till Mossakowski * paths -> things to add
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder * file -> ???
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder */
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maederstatic void munge_path(lua_State *L,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder const char *field,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder const char *sub_pat,
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski const char *rep_pat,
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski apr_pool_t *pool,
f534c0116096e25659ceaa57de030c497ce9345aTill Mossakowski apr_array_header_t *paths,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder const char *file)
f534c0116096e25659ceaa57de030c497ce9345aTill Mossakowski{
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder const char *current;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder const char *parent_dir;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder const char *pattern;
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski const char *modified;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder char *part;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski lua_getglobal(L, "package");
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_getfield(L, -1, field);
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski current = lua_tostring(L, -1);
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski
a205324331077b7d5a2c08fb3f0f57e5c029f9aaTill Mossakowski parent_dir = ap_make_dirstr_parent(pool, file);
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder pattern = apr_pstrcat(pool, parent_dir, sub_pat, NULL);
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder luaL_gsub(L, current, rep_pat, pattern);
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski lua_setfield(L, -3, field);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_getfield(L, -2, field);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder modified = lua_tostring(L, -1);
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski
242691238a8d1a89581751d782af87ec5d7470c0Till Mossakowski
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pop(L, 2);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski part = apr_pstrcat(pool, modified, ";", apr_array_pstrcat(pool, paths, ';'),
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski NULL);
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski lua_pushstring(L, part);
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski lua_setfield(L, -2, field);
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski lua_pop(L, 1); /* pop "package" off the stack */
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski}
f534c0116096e25659ceaa57de030c497ce9345aTill Mossakowski
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski#ifdef AP_ENABLE_LUAJIT
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowskistatic int loadjitmodule(lua_State *L, apr_pool_t *lifecycle_pool) {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski lua_getglobal(L, "require");
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski lua_pushliteral(L, "jit.");
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski lua_pushvalue(L, -3);
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski lua_concat(L, 2);
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski if (lua_pcall(L, 1, 1, 0)) {
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski const char *msg = lua_tostring(L, -1);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, lifecycle_pool, APLOGNO(01480)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Failed to init LuaJIT: %s", msg);
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski return 1;
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski }
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski lua_getfield(L, -1, "start");
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski lua_remove(L, -2); /* drop module table */
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski return 0;
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski}
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder#endif
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowskistatic apr_status_t vm_construct(lua_State **vm, void *params, apr_pool_t *lifecycle_pool)
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski{
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski lua_State* L;
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski ap_lua_vm_spec *spec = params;
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski
b3dca469a9e267d6d71acfdeca7bf284d0581dc7Till Mossakowski L = luaL_newstate();
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski#ifdef AP_ENABLE_LUAJIT
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski luaopen_jit(L);
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski#endif
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski luaL_openlibs(L);
d08907a7832988612fbc0682b216e150d1e738d2Christian Maeder if (spec->package_paths) {
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski munge_path(L,
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski "path", "?.lua", "./?.lua",
f534c0116096e25659ceaa57de030c497ce9345aTill Mossakowski lifecycle_pool,
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski spec->package_paths,
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski spec->file);
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski }
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski if (spec->package_cpaths) {
1a7b7802544aa94828d7f4e7be5788501c572934Till Mossakowski munge_path(L, "cpath", "?.so", "./?.so", lifecycle_pool,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder spec->package_cpaths, spec->file);
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder }
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski if (spec->cb) {
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski spec->cb(L, lifecycle_pool, spec->cb_arg);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski if (spec->bytecode && spec->bytecode_len > 0) {
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder luaL_loadbuffer(L, spec->bytecode, spec->bytecode_len, spec->file);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pcall(L, 0, LUA_MULTRET, 0);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder }
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski else {
242691238a8d1a89581751d782af87ec5d7470c0Till Mossakowski int rc;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, lifecycle_pool, APLOGNO(01481)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "loading lua file %s", spec->file);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder rc = luaL_loadfile(L, spec->file);
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski if (rc != 0) {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ap_log_perror(APLOG_MARK, APLOG_ERR, 0, lifecycle_pool, APLOGNO(01482)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder "Error loading %s: %s", spec->file,
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder rc == LUA_ERRMEM ? "memory allocation error"
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski : lua_tostring(L, 0));
f534c0116096e25659ceaa57de030c497ce9345aTill Mossakowski return APR_EBADF;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pcall(L, 0, LUA_MULTRET, 0);
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder }
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski#ifdef AP_ENABLE_LUAJIT
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski loadjitmodule(L, lifecycle_pool);
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till Mossakowski#endif
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lua_pushlightuserdata(L, lifecycle_pool);
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder lua_setfield(L, LUA_REGISTRYINDEX, "Apache2.Wombat.pool");
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski *vm = L;
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return APR_SUCCESS;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder}
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowski
242691238a8d1a89581751d782af87ec5d7470c0Till Mossakowski/**
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder * Function used to create a lua_State instance bound into the web
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder * server in the appropriate scope.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder */
b10d6cef708b7a659f2d3b367e8e0db0d03ae3f5Till MossakowskiAP_LUA_DECLARE(lua_State*)ap_lua_get_lua_state(apr_pool_t *lifecycle_pool,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ap_lua_vm_spec *spec)
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder{
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder lua_State *L = NULL;
e379124f467e5d0ef7d3c0ca238bff0521f70831Till Mossakowski
f534c0116096e25659ceaa57de030c497ce9345aTill Mossakowski if (apr_pool_userdata_get((void **)&L, spec->file,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lifecycle_pool) == APR_SUCCESS) {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder if(L==NULL) {
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, lifecycle_pool, APLOGNO(01483)
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski "creating lua_State with file %s", spec->file);
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski /* not available, so create */
6a57a555c8ef0a79aa5d20e1d721400dbffa564aMaciek Makowski
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski if(!vm_construct(&L, spec, lifecycle_pool)) {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder AP_DEBUG_ASSERT(L != NULL);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder apr_pool_userdata_set(L,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder spec->file,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder cleanup_lua,
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder lifecycle_pool);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder }
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder }
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski }
c0380b947eef252db81ee562246bb732555427f4Till Mossakowski /*}*/
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder return L;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder}
3476beb5baf84bef7cc7d627b130de9d48700399Christian Maeder