# HG changeset patch # User Matthew Wild # Date 1422707124 0 # Node ID c60c199cc7f04fd94ed6b0b471e0698218ee0c95 # Parent 6f39c58bdcc4d4d0db1be7ce06bfbf841c2fb241# Parent f0a2bdfd0ceac28c8bca921fc606b9676f7e68a9 Merge 0.10->trunk diff -r 6f39c58bdcc4 -r c60c199cc7f0 core/sessionmanager.lua --- a/core/sessionmanager.lua Mon Jan 26 15:27:19 2015 +0100 +++ b/core/sessionmanager.lua Sat Jan 31 12:25:24 2015 +0000 @@ -117,6 +117,16 @@ if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end -- We don't support binding multiple resources + local event_payload = { session = session, resource = resource }; + if hosts[session.host].events.fire_event("pre-resource-bind", event_payload) == false then + local err = event_payload.error; + if err then return nil, err.type, err.condition, err.text; end + return nil, "cancel", "not-allowed"; + else + -- In case a plugin wants to poke at it + resource = event_payload.resource; + end + resource = resourceprep(resource); resource = resource ~= "" and resource or uuid_generate(); --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing diff -r 6f39c58bdcc4 -r c60c199cc7f0 util/statistics.lua --- a/util/statistics.lua Mon Jan 26 15:27:19 2015 +0100 +++ b/util/statistics.lua Sat Jan 31 12:25:24 2015 +0000 @@ -8,7 +8,7 @@ local n = pc/100 * (length + 1); local k, d = m_floor(n), n%1; if k == 0 then - return arr[1]; + return arr[1] or 0; elseif k >= length then return arr[length]; end