httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Cawley <>
Subject mod_lua: package.loaded == apache2 (bug)
Date Thu, 26 Mar 2009 20:20:00 GMT
The function apl_load_apache2_lmodule, which is meant to load the
apache2 library is flawed in that it loads the library into the
package.loaded table and sets this as the global "apache2". It should
load it into a new table, and set this as the global "apache2" and
package.loaded.apache2. What follows is a small test script which
shows this (all tests _should_ pass, but most of the apache2 ones do
not). Also attached is a patch which fixes this.

---- begin code sample ----
function handle(req)
  local function assert(test)
    local status = loadstring('return '.. test)()
    req:write(test ..': '.. (status and "pass" or "FAIL") ..'\n')

  -- control tests
  assert [[string == require "string"]]
  assert "package.loaded.math == math"

  -- apache2 tests
  assert [[apache2 == require "apache2"]]
  assert "package.loaded.apache2 == apache2"
  assert "package.loaded ~= apache2"
  assert "apache2.apache2 == nil"
  assert "apache2.OK ~= nil"
  assert "package.loaded.apache2.OK ~= nil"
---- end code sample ----

View raw message