Mercurial > prosody-hg
comparison plugins/mod_bosh.lua @ 1865:388b125b784a
Merge with 0.5
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 02 Oct 2009 21:24:16 +0100 |
| parents | 2c72b725384e b9389286eece |
| children | 7456bb2a3458 |
comparison
equal
deleted
inserted
replaced
| 1862:115f274dd17f | 1865:388b125b784a |
|---|---|
| 256 end | 256 end |
| 257 core_process_stanza(session, stanza); | 257 core_process_stanza(session, stanza); |
| 258 end | 258 end |
| 259 end | 259 end |
| 260 | 260 |
| 261 local dead_sessions = {}; | |
| 261 function on_timer() | 262 function on_timer() |
| 262 -- log("debug", "Checking for requests soon to timeout..."); | 263 -- log("debug", "Checking for requests soon to timeout..."); |
| 263 -- Identify requests timing out within the next few seconds | 264 -- Identify requests timing out within the next few seconds |
| 264 local now = os_time() + 3; | 265 local now = os_time() + 3; |
| 265 for request in pairs(waiting_requests) do | 266 for request in pairs(waiting_requests) do |
| 272 end | 273 end |
| 273 end | 274 end |
| 274 end | 275 end |
| 275 | 276 |
| 276 now = now - 3; | 277 now = now - 3; |
| 278 local n_dead_sessions = 0; | |
| 277 for session, inactive_since in pairs(inactive_sessions) do | 279 for session, inactive_since in pairs(inactive_sessions) do |
| 278 if session.bosh_max_inactive then | 280 if session.bosh_max_inactive then |
| 279 if now - inactive_since > session.bosh_max_inactive then | 281 if now - inactive_since > session.bosh_max_inactive then |
| 280 (session.log or log)("debug", "BOSH client inactive too long, destroying session at %d", now); | 282 (session.log or log)("debug", "BOSH client inactive too long, destroying session at %d", now); |
| 281 sessions[session.sid] = nil; | 283 sessions[session.sid] = nil; |
| 282 inactive_sessions[session] = nil; | 284 inactive_sessions[session] = nil; |
| 283 sm_destroy_session(session, "BOSH client silent for over "..session.bosh_max_inactive.." seconds"); | 285 n_dead_sessions = n_dead_sessions + 1; |
| 286 dead_sessions[n_dead_sessions] = session; | |
| 284 end | 287 end |
| 285 else | 288 else |
| 286 inactive_sessions[session] = nil; | 289 inactive_sessions[session] = nil; |
| 287 end | 290 end |
| 288 end | 291 end |
| 292 | |
| 293 for i=1,n_dead_sessions do | |
| 294 local session = dead_sessions[i]; | |
| 295 dead_sessions[i] = nil; | |
| 296 sm_destroy_session(session, "BOSH client silent for over "..session.bosh_max_inactive.." seconds"); | |
| 297 end | |
| 289 end | 298 end |
| 290 | 299 |
| 291 local ports = module:get_option("bosh_ports") or { 5280 }; | 300 local ports = module:get_option("bosh_ports") or { 5280 }; |
| 292 httpserver.new_from_config(ports, "http-bind", handle_request); | 301 httpserver.new_from_config(ports, "http-bind", handle_request); |
| 293 | 302 |
