Skip to content

Commit d3a6c8a

Browse files
committed
add regression test which reproduces problem
1 parent a8400eb commit d3a6c8a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
_=[[
3+
. "${0%%/*}/regress.sh"
4+
exec runlua "$0" "$@"
5+
]]
6+
-- load dns.config first so that subsequent loads of DNS modules overwrite
7+
-- the config metatable
8+
local config = require"cqueues.dns.config"
9+
local resolver = require"cqueues.dns.resolver" -- ensure config mt reloaded
10+
require"regress".export".*"
11+
12+
-- config.new would fail because the :set method it depended upon is an
13+
-- interposed Lua function added to the userdata metatable. When subsequent
14+
-- modules which depended on the metatable definition were loaded, they
15+
-- called dnsL_loadall. dnsL_loadall defined all the internal metatables,
16+
-- which since commit 4d66661 had the effect of replacing any pre-existing
17+
-- __index field with a new table containing only the original C-defined
18+
-- methods. Previously cqs_newmetatable short-circuited when a metatable
19+
-- existed. The purpose of 4d66661 was to permit forced reloading of all Lua
20+
-- modules by clearing package.loaded; the original behavior resulted in
21+
-- modules interposing the same functions multiple times.
22+
info"creating resolver config object"
23+
local cfg = config.new{
24+
nameserver = { "1.2.3.4" },
25+
lookup = { "file", "bind", "cache" },
26+
options = { edns0 = true },
27+
}
28+
29+
info("resolv.conf:")
30+
for ln in tostring(cfg):gmatch("[^\n]+") do
31+
info(" %s", ln)
32+
end
33+
34+
say"OK"

0 commit comments

Comments
 (0)