Mercurial > prosody-hg
comparison util/sasl.lua @ 3365:32dc830d976c
util.sasl, util.sasl_cyrus: Updated method:mechanisms() to cache and re-use list of mechanisms.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Wed, 14 Jul 2010 20:10:35 +0500 |
| parents | 6a5d77924949 |
| children | a2a242321901 |
comparison
equal
deleted
inserted
replaced
| 3364:6a5d77924949 | 3365:32dc830d976c |
|---|---|
| 86 end | 86 end |
| 87 end | 87 end |
| 88 | 88 |
| 89 -- get a list of possible SASL mechanims to use | 89 -- get a list of possible SASL mechanims to use |
| 90 function method:mechanisms() | 90 function method:mechanisms() |
| 91 local mechanisms = {} | 91 local mechanisms = self.mechs; |
| 92 for backend, f in pairs(self.profile) do | 92 if not mechanisms then |
| 93 if backend_mechanism[backend] then | 93 mechanisms = {} |
| 94 for _, mechanism in ipairs(backend_mechanism[backend]) do | 94 for backend, f in pairs(self.profile) do |
| 95 if not self.restrict:contains(mechanism) then | 95 if backend_mechanism[backend] then |
| 96 mechanisms[mechanism] = true; | 96 for _, mechanism in ipairs(backend_mechanism[backend]) do |
| 97 if not self.restrict:contains(mechanism) then | |
| 98 mechanisms[mechanism] = true; | |
| 99 end | |
| 97 end | 100 end |
| 98 end | 101 end |
| 99 end | 102 end |
| 103 self.mechs = mechanisms; | |
| 100 end | 104 end |
| 101 self.mechs = mechanisms; | |
| 102 return mechanisms; | 105 return mechanisms; |
| 103 end | 106 end |
| 104 | 107 |
| 105 -- select a mechanism to use | 108 -- select a mechanism to use |
| 106 function method:select(mechanism) | 109 function method:select(mechanism) |
