Mercurial > prosody-hg
annotate util/pluginloader.lua @ 13652:a08065207ef0
net.server_epoll: Call :shutdown() on TLS sockets when supported
Comment from Matthew:
This fixes a potential issue where the Prosody process gets blocked on sockets
waiting for them to close. Unlike non-TLS sockets, closing a TLS socket sends
layer 7 data, and this can cause problems for sockets which are in the process
of being cleaned up.
This depends on LuaSec changes which are not yet upstream.
From Martijn's original email:
So first my analysis of luasec. in ssl.c the socket is put into blocking
mode right before calling SSL_shutdown() inside meth_destroy(). My best
guess to why this is is because meth_destroy is linked to the __close
and __gc methods, which can't exactly be called multiple times and
luasec does want to make sure that a tls session is shutdown as clean
as possible.
I can't say I disagree with this reasoning and don't want to change this
behaviour. My solution to this without changing the current behaviour is
to introduce a shutdown() method. I am aware that this overlaps in a
conflicting way with tcp's shutdown method, but it stays close to the
OpenSSL name. This method calls SSL_shutdown() in the current
(non)blocking mode of the underlying socket and returns a boolean
whether or not the shutdown is completed (matching SSL_shutdown()'s 0
or 1 return values), and returns the familiar ssl_ioerror() strings on
error with a false for completion. This error can then be used to
determine if we have wantread/wantwrite to finalize things. Once
meth_shutdown() has been called once a shutdown flag will be set, which
indicates to meth_destroy() that the SSL_shutdown() has been handled
by the application and it shouldn't be needed to set the socket to
blocking mode. I've left the SSL_shutdown() call in the
LSEC_STATE_CONNECTED to prevent TOCTOU if the application reaches a
timeout for the shutdown code, which might allow SSL_shutdown() to
clean up anyway at the last possible moment.
Another thing I've changed to luasec is the call to socket_setblocking()
right before calling close(2) in socket_destroy() in usocket.c.
According to the latest POSIX[0]:
Note that the requirement for close() on a socket to block for up to
the current linger interval is not conditional on the O_NONBLOCK
setting.
Which I read to mean that removing O_NONBLOCK on the socket before close
doesn't impact the behaviour and only causes noise in system call
tracers. I didn't touch the windows bits of this, since I don't do
windows.
For the prosody side of things I've made the TLS shutdown bits resemble
interface:onwritable(), and put it under a combined guard of self._tls
and self.conn.shutdown. The self._tls bit is there to prevent getting
stuck on this condition, and self.conn.shutdown is there to prevent the
code being called by instances where the patched luasec isn't deployed.
The destroy() method can be called from various places and is read by
me as the "we give up" error path. To accommodate for these unexpected
entrypoints I've added a single call to self.conn:shutdown() to prevent
the socket being put into blocking mode. I have no expectations that
there is any other use here. Same as previous, the self.conn.shutdown
check is there to make sure it's not called on unpatched luasec
deployments and self._tls is there to make sure we don't call shutdown()
on tcp sockets.
I wouldn't recommend logging of the conn:shutdown() error inside
close(), since a lot of clients simply close the connection before
SSL_shutdown() is done.
| author | Martijn van Duren <martijn@openbsd.org> |
|---|---|
| date | Thu, 06 Feb 2025 15:04:38 +0000 |
| parents | d10957394a3c |
| children | dde0ce03049b |
| rev | line source |
|---|---|
|
1522
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1441
diff
changeset
|
1 -- Prosody IM |
|
2923
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
1522
diff
changeset
|
2 -- Copyright (C) 2008-2010 Matthew Wild |
|
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
1522
diff
changeset
|
3 -- Copyright (C) 2008-2010 Waqas Hussain |
|
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
5073
diff
changeset
|
4 -- |
|
1522
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1441
diff
changeset
|
5 -- This project is MIT/X11 licensed. Please see the |
|
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1441
diff
changeset
|
6 -- COPYING file in the source package for more information. |
|
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1441
diff
changeset
|
7 -- |
|
8382
e5d00bf4a4d5
util: Various minor changes to please [luacheck]
Kim Alvefur <zash@zash.se>
parents:
7115
diff
changeset
|
8 -- luacheck: ignore 113/CFG_PLUGINDIR |
|
1522
569d58d21612
Add copyright header to those files missing one
Matthew Wild <mwild1@gmail.com>
parents:
1441
diff
changeset
|
9 |
|
4121
ea7e3f22f898
util.pluginloader: Add support for multiple plugin directories.
Waqas Hussain <waqas20@gmail.com>
parents:
3411
diff
changeset
|
10 local dir_sep, path_sep = package.config:match("^(%S+)%s(%S+)"); |
|
11129
387d442497e7
util.pluginloader: Extract Lua version once
Kim Alvefur <zash@zash.se>
parents:
10205
diff
changeset
|
11 local lua_version = _VERSION:match(" (.+)$"); |
|
4121
ea7e3f22f898
util.pluginloader: Add support for multiple plugin directories.
Waqas Hussain <waqas20@gmail.com>
parents:
3411
diff
changeset
|
12 local plugin_dir = {}; |
|
ea7e3f22f898
util.pluginloader: Add support for multiple plugin directories.
Waqas Hussain <waqas20@gmail.com>
parents:
3411
diff
changeset
|
13 for path in (CFG_PLUGINDIR or "./plugins/"):gsub("[/\\]", dir_sep):gmatch("[^"..path_sep.."]+") do |
|
ea7e3f22f898
util.pluginloader: Add support for multiple plugin directories.
Waqas Hussain <waqas20@gmail.com>
parents:
3411
diff
changeset
|
14 path = path..dir_sep; -- add path separator to path end |
|
12387
05c250fa335a
Spelling: Fix various spelling mistakes (thanks timeless)
Kim Alvefur <zash@zash.se>
parents:
12255
diff
changeset
|
15 path = path:gsub(dir_sep..dir_sep.."+", dir_sep); -- coalesce multiple separators |
|
4121
ea7e3f22f898
util.pluginloader: Add support for multiple plugin directories.
Waqas Hussain <waqas20@gmail.com>
parents:
3411
diff
changeset
|
16 plugin_dir[#plugin_dir + 1] = path; |
|
ea7e3f22f898
util.pluginloader: Add support for multiple plugin directories.
Waqas Hussain <waqas20@gmail.com>
parents:
3411
diff
changeset
|
17 end |
|
1359
015d624a2a71
util.pluginloader: Initial commit - a plugin resource loader
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
18 |
|
5073
ecc89a60b2ba
util.pluginloader: Remove unused imports
Matthew Wild <mwild1@gmail.com>
parents:
5072
diff
changeset
|
19 local io_open = io.open; |
|
12975
d10957394a3c
util: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
12387
diff
changeset
|
20 local envload = require "prosody.util.envload".envload; |
|
2276
d9302be05f86
util.pluginloader: Support for fetching plugins from the data store
Matthew Wild <mwild1@gmail.com>
parents:
1522
diff
changeset
|
21 |
|
12250
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
22 local pluginloader_methods = {}; |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
23 local pluginloader_mt = { __index = pluginloader_methods }; |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
24 |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
25 function pluginloader_methods:load_file(names) |
|
4149
3c1b153c2856
util.pluginloader: Return full file path from internal file loader on success, not just the name.
Waqas Hussain <waqas20@gmail.com>
parents:
4121
diff
changeset
|
26 local file, err, path; |
|
12251
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
27 local load_filter_cb = self._options.load_filter_cb; |
|
4121
ea7e3f22f898
util.pluginloader: Add support for multiple plugin directories.
Waqas Hussain <waqas20@gmail.com>
parents:
3411
diff
changeset
|
28 for i=1,#plugin_dir do |
|
4154
3785a9bb7f11
util.pluginloader: Rewritten resource loading to be cleaner, and added support for prosody-modules directory layout. "/" in plugin names is no longer supported.
Waqas Hussain <waqas20@gmail.com>
parents:
4152
diff
changeset
|
29 for j=1,#names do |
|
3785a9bb7f11
util.pluginloader: Rewritten resource loading to be cleaner, and added support for prosody-modules directory layout. "/" in plugin names is no longer supported.
Waqas Hussain <waqas20@gmail.com>
parents:
4152
diff
changeset
|
30 path = plugin_dir[i]..names[j]; |
|
3785a9bb7f11
util.pluginloader: Rewritten resource loading to be cleaner, and added support for prosody-modules directory layout. "/" in plugin names is no longer supported.
Waqas Hussain <waqas20@gmail.com>
parents:
4152
diff
changeset
|
31 file, err = io_open(path); |
|
3785a9bb7f11
util.pluginloader: Rewritten resource loading to be cleaner, and added support for prosody-modules directory layout. "/" in plugin names is no longer supported.
Waqas Hussain <waqas20@gmail.com>
parents:
4152
diff
changeset
|
32 if file then |
|
3785a9bb7f11
util.pluginloader: Rewritten resource loading to be cleaner, and added support for prosody-modules directory layout. "/" in plugin names is no longer supported.
Waqas Hussain <waqas20@gmail.com>
parents:
4152
diff
changeset
|
33 local content = file:read("*a"); |
|
3785a9bb7f11
util.pluginloader: Rewritten resource loading to be cleaner, and added support for prosody-modules directory layout. "/" in plugin names is no longer supported.
Waqas Hussain <waqas20@gmail.com>
parents:
4152
diff
changeset
|
34 file:close(); |
|
12251
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
35 local metadata; |
|
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
36 if load_filter_cb then |
|
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
37 path, content, metadata = load_filter_cb(path, content); |
|
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
38 end |
|
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
39 if content and path then |
|
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
40 return content, path, metadata; |
|
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
41 end |
|
4154
3785a9bb7f11
util.pluginloader: Rewritten resource loading to be cleaner, and added support for prosody-modules directory layout. "/" in plugin names is no longer supported.
Waqas Hussain <waqas20@gmail.com>
parents:
4152
diff
changeset
|
42 end |
|
3785a9bb7f11
util.pluginloader: Rewritten resource loading to be cleaner, and added support for prosody-modules directory layout. "/" in plugin names is no longer supported.
Waqas Hussain <waqas20@gmail.com>
parents:
4152
diff
changeset
|
43 end |
|
4121
ea7e3f22f898
util.pluginloader: Add support for multiple plugin directories.
Waqas Hussain <waqas20@gmail.com>
parents:
3411
diff
changeset
|
44 end |
|
4154
3785a9bb7f11
util.pluginloader: Rewritten resource loading to be cleaner, and added support for prosody-modules directory layout. "/" in plugin names is no longer supported.
Waqas Hussain <waqas20@gmail.com>
parents:
4152
diff
changeset
|
45 return file, err; |
|
1359
015d624a2a71
util.pluginloader: Initial commit - a plugin resource loader
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
46 end |
|
015d624a2a71
util.pluginloader: Initial commit - a plugin resource loader
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
47 |
|
12250
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
48 function pluginloader_methods:load_resource(plugin, resource) |
|
12251
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
49 resource = resource or "mod_"..plugin..".lua"; |
|
4154
3785a9bb7f11
util.pluginloader: Rewritten resource loading to be cleaner, and added support for prosody-modules directory layout. "/" in plugin names is no longer supported.
Waqas Hussain <waqas20@gmail.com>
parents:
4152
diff
changeset
|
50 local names = { |
|
6029
dd3d4cfbd3cb
util.pluginloader: Always use path separator from package.config (thanks Junne)
Kim Alvefur <zash@zash.se>
parents:
5073
diff
changeset
|
51 "mod_"..plugin..dir_sep..plugin..dir_sep..resource; -- mod_hello/hello/mod_hello.lua |
|
dd3d4cfbd3cb
util.pluginloader: Always use path separator from package.config (thanks Junne)
Kim Alvefur <zash@zash.se>
parents:
5073
diff
changeset
|
52 "mod_"..plugin..dir_sep..resource; -- mod_hello/mod_hello.lua |
|
dd3d4cfbd3cb
util.pluginloader: Always use path separator from package.config (thanks Junne)
Kim Alvefur <zash@zash.se>
parents:
5073
diff
changeset
|
53 plugin..dir_sep..resource; -- hello/mod_hello.lua |
|
dd3d4cfbd3cb
util.pluginloader: Always use path separator from package.config (thanks Junne)
Kim Alvefur <zash@zash.se>
parents:
5073
diff
changeset
|
54 resource; -- mod_hello.lua |
|
11130
10485a3ef78b
util.pluginloader: Look for top level mod_something.lua in luarocks-style tree
Kim Alvefur <zash@zash.se>
parents:
11129
diff
changeset
|
55 "share"..dir_sep.."lua"..dir_sep..lua_version..dir_sep..resource; |
|
10205
ff8de86b75f0
util.pluginloader: Added a new path to the variable local_names
João Duarte <jvsDuarte08@gmail.com>
parents:
8382
diff
changeset
|
56 "share"..dir_sep.."lua"..dir_sep..lua_version..dir_sep.."mod_"..plugin..dir_sep..resource; |
|
4154
3785a9bb7f11
util.pluginloader: Rewritten resource loading to be cleaner, and added support for prosody-modules directory layout. "/" in plugin names is no longer supported.
Waqas Hussain <waqas20@gmail.com>
parents:
4152
diff
changeset
|
57 }; |
|
3410
32b018eeeb3b
util.pluginloader: Fix loading of plugins, plugin libraries and resources in subfolders (e.g., when loading 'a/b', load 'a/mod_b.lua', and not 'mod_a/b.lua').
Waqas Hussain <waqas20@gmail.com>
parents:
3233
diff
changeset
|
58 |
|
12250
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
59 return self:load_file(names); |
|
1359
015d624a2a71
util.pluginloader: Initial commit - a plugin resource loader
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
60 end |
|
015d624a2a71
util.pluginloader: Initial commit - a plugin resource loader
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
61 |
|
12250
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
62 function pluginloader_methods:load_code(plugin, resource, env) |
|
12251
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
63 local content, err, metadata = self:load_resource(plugin, resource); |
|
1359
015d624a2a71
util.pluginloader: Initial commit - a plugin resource loader
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
64 if not content then return content, err; end |
|
4150
2894ca33ec45
util.pluginloader: Return file path on success in pluginloader.load_code().
Waqas Hussain <waqas20@gmail.com>
parents:
4149
diff
changeset
|
65 local path = err; |
|
5021
85b2689dbcfe
Eliminate direct setfenv usage
Florian Zeitz <florob@babelmonkeys.de>
parents:
4154
diff
changeset
|
66 local f, err = envload(content, "@"..path, env); |
|
4150
2894ca33ec45
util.pluginloader: Return file path on success in pluginloader.load_code().
Waqas Hussain <waqas20@gmail.com>
parents:
4149
diff
changeset
|
67 if not f then return f, err; end |
|
12251
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
68 return f, path, metadata; |
|
1359
015d624a2a71
util.pluginloader: Initial commit - a plugin resource loader
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
69 end |
|
015d624a2a71
util.pluginloader: Initial commit - a plugin resource loader
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
70 |
|
12250
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
71 function pluginloader_methods:load_code_ext(plugin, resource, extension, env) |
|
12251
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
72 local content, err, metadata = self:load_resource(plugin, resource.."."..extension); |
|
11131
40abef01f4b9
util.pluginloader: Look for module libs in mod_plugin/lib.lua
Kim Alvefur <zash@zash.se>
parents:
11130
diff
changeset
|
73 if not content and extension == "lib.lua" then |
|
12251
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
74 content, err, metadata = self:load_resource(plugin, resource..".lua"); |
|
11131
40abef01f4b9
util.pluginloader: Look for module libs in mod_plugin/lib.lua
Kim Alvefur <zash@zash.se>
parents:
11130
diff
changeset
|
75 end |
|
7115
805d068d2fd5
modulemanager, util.pluginloader: Move logic for locating some module libraries to pluginloader, to fix problems with non-filesystem errors being masked by the second load_code call
Matthew Wild <mwild1@gmail.com>
parents:
6777
diff
changeset
|
76 if not content then |
|
12251
21ed12cfe300
util.pluginloader: Support for a per-file load filter
Matthew Wild <mwild1@gmail.com>
parents:
12250
diff
changeset
|
77 content, err, metadata = self:load_resource(resource, resource.."."..extension); |
|
7115
805d068d2fd5
modulemanager, util.pluginloader: Move logic for locating some module libraries to pluginloader, to fix problems with non-filesystem errors being masked by the second load_code call
Matthew Wild <mwild1@gmail.com>
parents:
6777
diff
changeset
|
78 if not content then |
|
805d068d2fd5
modulemanager, util.pluginloader: Move logic for locating some module libraries to pluginloader, to fix problems with non-filesystem errors being masked by the second load_code call
Matthew Wild <mwild1@gmail.com>
parents:
6777
diff
changeset
|
79 return content, err; |
|
805d068d2fd5
modulemanager, util.pluginloader: Move logic for locating some module libraries to pluginloader, to fix problems with non-filesystem errors being masked by the second load_code call
Matthew Wild <mwild1@gmail.com>
parents:
6777
diff
changeset
|
80 end |
|
805d068d2fd5
modulemanager, util.pluginloader: Move logic for locating some module libraries to pluginloader, to fix problems with non-filesystem errors being masked by the second load_code call
Matthew Wild <mwild1@gmail.com>
parents:
6777
diff
changeset
|
81 end |
|
805d068d2fd5
modulemanager, util.pluginloader: Move logic for locating some module libraries to pluginloader, to fix problems with non-filesystem errors being masked by the second load_code call
Matthew Wild <mwild1@gmail.com>
parents:
6777
diff
changeset
|
82 local path = err; |
|
805d068d2fd5
modulemanager, util.pluginloader: Move logic for locating some module libraries to pluginloader, to fix problems with non-filesystem errors being masked by the second load_code call
Matthew Wild <mwild1@gmail.com>
parents:
6777
diff
changeset
|
83 local f, err = envload(content, "@"..path, env); |
|
805d068d2fd5
modulemanager, util.pluginloader: Move logic for locating some module libraries to pluginloader, to fix problems with non-filesystem errors being masked by the second load_code call
Matthew Wild <mwild1@gmail.com>
parents:
6777
diff
changeset
|
84 if not f then return f, err; end |
|
12255
a3ad9cf740d6
util.pluginloader: Fix method to return any module metadata (luacheck)
Matthew Wild <mwild1@gmail.com>
parents:
12251
diff
changeset
|
85 return f, path, metadata; |
|
7115
805d068d2fd5
modulemanager, util.pluginloader: Move logic for locating some module libraries to pluginloader, to fix problems with non-filesystem errors being masked by the second load_code call
Matthew Wild <mwild1@gmail.com>
parents:
6777
diff
changeset
|
86 end |
|
805d068d2fd5
modulemanager, util.pluginloader: Move logic for locating some module libraries to pluginloader, to fix problems with non-filesystem errors being masked by the second load_code call
Matthew Wild <mwild1@gmail.com>
parents:
6777
diff
changeset
|
87 |
|
12250
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
88 local function init(options) |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
89 return setmetatable({ |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
90 _options = options or {}; |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
91 }, pluginloader_mt); |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
92 end |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
93 |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
94 local function bind(self, method) |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
95 return function (...) |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
96 return method(self, ...); |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
97 end; |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
98 end |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
99 |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
100 local default_loader = init(); |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
101 |
|
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6031
diff
changeset
|
102 return { |
|
12250
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
103 load_file = bind(default_loader, default_loader.load_file); |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
104 load_resource = bind(default_loader, default_loader.load_resource); |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
105 load_code = bind(default_loader, default_loader.load_code); |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
106 load_code_ext = bind(default_loader, default_loader.load_code_ext); |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
107 |
|
e157e5c79daa
util.pluginloader: Support for multiple pluginloader instances, and options
Matthew Wild <mwild1@gmail.com>
parents:
11131
diff
changeset
|
108 init = init; |
|
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6031
diff
changeset
|
109 }; |
