diff options
author | Tobias Markmann <tm@ayena.de> | 2009-03-03 17:48:04 +0100 |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2009-03-03 17:48:04 +0100 |
commit | 7a7a89844a038b071f02fd1af309ba9ebbcda7de (patch) | |
tree | 73946c977be10a965d59de85b3ce6ba3743bc771 /plugins/mod_bosh.lua | |
parent | 3d1e7adbbc0afb8395f02ecd42fe3c38ce6a8d36 (diff) | |
parent | b6b9906c3c653935b55ad79ad4a2c41118f0a0e3 (diff) | |
download | prosody-7a7a89844a038b071f02fd1af309ba9ebbcda7de.tar.gz prosody-7a7a89844a038b071f02fd1af309ba9ebbcda7de.zip |
Merged with main tip.
Diffstat (limited to 'plugins/mod_bosh.lua')
-rw-r--r-- | plugins/mod_bosh.lua | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua index df89f88e..4d0f5cd9 100644 --- a/plugins/mod_bosh.lua +++ b/plugins/mod_bosh.lua @@ -32,6 +32,19 @@ local inactive_sessions = {}; -- Sessions which have no open requests local waiting_requests = {}; function on_destroy_request(request) waiting_requests[request] = nil; + local session = request.session; + if session then + local requests = session.requests; + for i,r in pairs(requests) do + if r == request then requests[i] = nil; break; end + end + + -- If this session now has no requests open, mark it as inactive + if #requests == 0 and session.bosh_max_inactive and not inactive_sessions[session] then + inactive_sessions[session] = os_time(); + (session.log or log)("debug", "BOSH session marked as inactive at %d", inactive_sessions[session]); + end + end end function handle_request(method, body, request) @@ -151,10 +164,6 @@ function stream_callbacks.streamopened(request, attr) end elseif s ~= "" then log("debug", "Saved to send buffer because there are %d open requests", #r); - if session.bosh_max_inactive and not inactive_sessions[session] then - inactive_sessions[session] = os_time(); - (session.log or log)("debug", "BOSH session marked as inactive at %d", inactive_sessions[session]); - end -- Hmm, no requests are open :( t_insert(session.send_buffer, tostring(s)); log("debug", "There are now %d things in the send_buffer", #session.send_buffer); @@ -243,7 +252,6 @@ function on_timer() (session.log or log)("debug", "BOSH client inactive too long, destroying session at %d", now); sessions[session.sid] = nil; inactive_sessions[session] = nil; - session.bosh_max_inactive = nil; -- Stop us marking this session as active during destroy sm_destroy_session(session, "BOSH client silent for over "..session.bosh_max_inactive.." seconds"); end else |