Fixed: kick_old resource conflict resolution policy could fail with a backtrace
authorWaqas Hussain <waqas20@gmail.com>
Thu, 12 Feb 2009 13:23:00 +0000 (18:23 +0500)
committerWaqas Hussain <waqas20@gmail.com>
Thu, 12 Feb 2009 13:23:00 +0000 (18:23 +0500)
core/sessionmanager.lua

index 571ce1fe43e6826f650e41a52b061f02c89b1291..42b168e88bd415c7f74ec73185b9a5dabc190ae4 100644 (file)
@@ -126,10 +126,13 @@ function bind_resource(session, resource)
                        elseif policy == "kick_new" then
                                return nil, "cancel", "conflict", "Resource already exists";
                        else -- if policy == "kick_old" then
-                               hosts[session.host].sessions[session.username].sessions[resource]:close {
+                               sessions[resource]:close {
                                        condition = "conflict";
                                        text = "Replaced by new connection";
                                };
+                               if not next(sessions) then
+                                       hosts[session.host].sessions[session.username] = { sessions = sessions };
+                               end
                        end
                        if increment and sessions[resource] then
                                local count = 1;