diff options
author | Waqas Hussain <waqas20@gmail.com> | 2010-07-14 20:10:35 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2010-07-14 20:10:35 +0500 |
commit | 81c3a58d1fed9f0e5713d005181b871c12843fd3 (patch) | |
tree | 5befdaef4fc6392648e1979577bf19cbec1e4516 /util/sasl.lua | |
parent | d9319436f0a9e592f57fbc1958a2e2936cc3e675 (diff) | |
download | prosody-81c3a58d1fed9f0e5713d005181b871c12843fd3.tar.gz prosody-81c3a58d1fed9f0e5713d005181b871c12843fd3.zip |
util.sasl, util.sasl_cyrus: Updated method:mechanisms() to cache and re-use list of mechanisms.
Diffstat (limited to 'util/sasl.lua')
-rw-r--r-- | util/sasl.lua | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/util/sasl.lua b/util/sasl.lua index a7e151a2..8f91f7b5 100644 --- a/util/sasl.lua +++ b/util/sasl.lua @@ -88,17 +88,20 @@ end -- get a list of possible SASL mechanims to use function method:mechanisms() - local mechanisms = {} - for backend, f in pairs(self.profile) do - if backend_mechanism[backend] then - for _, mechanism in ipairs(backend_mechanism[backend]) do - if not self.restrict:contains(mechanism) then - mechanisms[mechanism] = true; + local mechanisms = self.mechs; + if not mechanisms then + mechanisms = {} + for backend, f in pairs(self.profile) do + if backend_mechanism[backend] then + for _, mechanism in ipairs(backend_mechanism[backend]) do + if not self.restrict:contains(mechanism) then + mechanisms[mechanism] = true; + end end end end + self.mechs = mechanisms; end - self.mechs = mechanisms; return mechanisms; end |