# HG changeset patch # User tmolitor # Date 1493060243 -7200 # Node ID caabb980d1d829e2c1b1882b7f7534f766116bdd # Parent d96831e46b64237561109314ad632ba9747ffe3b# Parent 7a5dae85f26f0b5c9f2049d20d87e0b5b09f45e0 Merge commit diff -r 7a5dae85f26f -r caabb980d1d8 mod_smacks/mod_smacks.lua --- a/mod_smacks/mod_smacks.lua Fri Apr 21 16:46:09 2017 +0100 +++ b/mod_smacks/mod_smacks.lua Mon Apr 24 20:57:23 2017 +0200 @@ -49,8 +49,16 @@ if not cache then local store = {}; return { - get = function(user, key) return store[key]; end; - set = function(user, key, value) store[key] = value; end; + get = function(user, key) + if not user then return nil; end + if not key then return nil; end + return store[key]; + end; + set = function(user, key, value) + if not user then return nil; end + if not key then return nil; end + store[key] = value; + end; }; end @@ -58,12 +66,16 @@ local stores = {}; return { get = function(user, key) + if not user then return nil; end + if not key then return nil; end if not stores[user] then stores[user] = cache.new(max_entries, evict_callback); end return stores[user]:get(key); end; set = function(user, key, value) + if not user then return nil; end + if not key then return nil; end if not stores[user] then stores[user] = cache.new(max_entries, evict_callback); end stores[user]:set(key, value); -- remove empty caches completely @@ -73,7 +85,7 @@ end local old_session_registry = init_session_cache(max_old_sessions, nil); local session_registry = init_session_cache(max_hibernated_sessions, function(resumption_token, session) - if session.destroyed then return; end + if session.destroyed then return true; end -- destroyed session can always be removed from cache session.log("warn", "User has too much hibernated sessions, removing oldest session (token: %s)", resumption_token); -- store old session's h values on force delete -- save only actual h value and username/host (for security)