Software / code / prosody
Comparison
plugins/mod_bosh.lua @ 5660:df077bc8f019
mod_bosh: Make waiting_requests and dead_sessions shared to preserve across reloads
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 08 Jun 2013 18:08:18 +0100 |
| parent | 5658:97c1c1bdd7bc |
| child | 5667:0bf1cdea43f6 |
comparison
equal
deleted
inserted
replaced
| 5659:9f9de8078164 | 5660:df077bc8f019 |
|---|---|
| 60 | 60 |
| 61 -- All sessions, and sessions that have no requests open | 61 -- All sessions, and sessions that have no requests open |
| 62 local sessions, inactive_sessions = module:shared("sessions", "inactive_sessions"); | 62 local sessions, inactive_sessions = module:shared("sessions", "inactive_sessions"); |
| 63 | 63 |
| 64 -- Used to respond to idle sessions (those with waiting requests) | 64 -- Used to respond to idle sessions (those with waiting requests) |
| 65 local waiting_requests = {}; | 65 local waiting_requests = module:shared("waiting_requests"); |
| 66 function on_destroy_request(request) | 66 function on_destroy_request(request) |
| 67 log("debug", "Request destroyed: %s", tostring(request)); | 67 log("debug", "Request destroyed: %s", tostring(request)); |
| 68 waiting_requests[request] = nil; | 68 waiting_requests[request] = nil; |
| 69 local session = sessions[request.context.sid]; | 69 local session = sessions[request.context.sid]; |
| 70 if session then | 70 if session then |
| 395 else | 395 else |
| 396 session:close({ condition = "bad-format", text = "Error processing stream" }); | 396 session:close({ condition = "bad-format", text = "Error processing stream" }); |
| 397 end | 397 end |
| 398 end | 398 end |
| 399 | 399 |
| 400 local dead_sessions = {}; | 400 local dead_sessions = module:shared("dead_sessions"); |
| 401 function on_timer() | 401 function on_timer() |
| 402 -- log("debug", "Checking for requests soon to timeout..."); | 402 -- log("debug", "Checking for requests soon to timeout..."); |
| 403 -- Identify requests timing out within the next few seconds | 403 -- Identify requests timing out within the next few seconds |
| 404 local now = os_time() + 3; | 404 local now = os_time() + 3; |
| 405 for request, reply_before in pairs(waiting_requests) do | 405 for request, reply_before in pairs(waiting_requests) do |