Comparison

core/sessionmanager.lua @ 563:099d8a102deb

Add TLS socket to readlist before handshake starts, fixes major slow-down on TLS connections
author Matthew Wild <mwild1@gmail.com>
date Fri, 05 Dec 2008 19:24:01 +0000
parent 532:c24471cadc2c
child 565:3a49d85cafbc
comparison
equal deleted inserted replaced
562:04ee161d936b 563:099d8a102deb
33 local error = error; 33 local error = error;
34 local uuid_generate = require "util.uuid".generate; 34 local uuid_generate = require "util.uuid".generate;
35 local rm_load_roster = require "core.rostermanager".load_roster; 35 local rm_load_roster = require "core.rostermanager".load_roster;
36 local config_get = require "core.configmanager".get; 36 local config_get = require "core.configmanager".get;
37 37
38 local gettime = require "socket".gettime;
39
38 local st = require "util.stanza"; 40 local st = require "util.stanza";
39 41
40 local newproxy = newproxy; 42 local newproxy = newproxy;
41 local getmetatable = getmetatable; 43 local getmetatable = getmetatable;
42 44
43 module "sessionmanager" 45 module "sessionmanager"
44 46
45 local open_sessions = 0; 47 local open_sessions = 0;
46 48
47 function new_session(conn) 49 function new_session(conn)
48 local session = { conn = conn, priority = 0, type = "c2s_unauthed" }; 50 local session = { conn = conn, priority = 0, type = "c2s_unauthed", conntime = gettime() };
49 if true then 51 if true then
50 session.trace = newproxy(true); 52 session.trace = newproxy(true);
51 getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; print("Session got collected, now "..open_sessions.." sessions are allocated") end; 53 getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; print("Session got collected, now "..open_sessions.." sessions are allocated") end;
52 end 54 end
53 open_sessions = open_sessions + 1; 55 open_sessions = open_sessions + 1;
107 function bind_resource(session, resource) 109 function bind_resource(session, resource)
108 if not session.username then return nil, "auth", "not-authorized", "Cannot bind resource before authentication"; end 110 if not session.username then return nil, "auth", "not-authorized", "Cannot bind resource before authentication"; end
109 if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end 111 if session.resource then return nil, "cancel", "already-bound", "Cannot bind multiple resources on a single connection"; end
110 -- We don't support binding multiple resources 112 -- We don't support binding multiple resources
111 113
114 session.conntimetotal = gettime()-session.conntime;
115
112 resource = resource or uuid_generate(); 116 resource = resource or uuid_generate();
113 --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing 117 --FIXME: Randomly-generated resources must be unique per-user, and never conflict with existing
114 118
115 if not hosts[session.host].sessions[session.username] then 119 if not hosts[session.host].sessions[session.username] then
116 hosts[session.host].sessions[session.username] = { sessions = {} }; 120 hosts[session.host].sessions[session.username] = { sessions = {} };