Software /
code /
prosody
Comparison
core/sessionmanager.lua @ 4548:e6e5c76ff009
sessionmanager, mod_c2s: Move timeout logic to mod_c2s
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 23 Jan 2012 00:56:57 +0000 |
parent | 4543:db27a4c18b6a |
child | 4552:414d857ee125 |
comparison
equal
deleted
inserted
replaced
4547:d9d777e97e8f | 4548:e6e5c76ff009 |
---|---|
26 local add_task = require "util.timer".add_task; | 26 local add_task = require "util.timer".add_task; |
27 local gettime = require "socket".gettime; | 27 local gettime = require "socket".gettime; |
28 | 28 |
29 local st = require "util.stanza"; | 29 local st = require "util.stanza"; |
30 | 30 |
31 local c2s_timeout = config_get("*", "core", "c2s_timeout"); | |
32 | |
33 local newproxy = newproxy; | 31 local newproxy = newproxy; |
34 local getmetatable = getmetatable; | 32 local getmetatable = getmetatable; |
35 | 33 |
36 module "sessionmanager" | 34 module "sessionmanager" |
37 | 35 |
60 end | 58 end |
61 end | 59 end |
62 session.ip = conn:ip(); | 60 session.ip = conn:ip(); |
63 local conn_name = "c2s"..tostring(conn):match("[a-f0-9]+$"); | 61 local conn_name = "c2s"..tostring(conn):match("[a-f0-9]+$"); |
64 session.log = logger.init(conn_name); | 62 session.log = logger.init(conn_name); |
65 | |
66 if c2s_timeout then | |
67 add_task(c2s_timeout, function () | |
68 if session.type == "c2s_unauthed" then | |
69 session:close("connection-timeout"); | |
70 end | |
71 end); | |
72 end | |
73 | 63 |
74 return session; | 64 return session; |
75 end | 65 end |
76 | 66 |
77 local resting_session = { -- Resting, not dead | 67 local resting_session = { -- Resting, not dead |