diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-02-19 15:18:44 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-02-19 15:18:44 +0000 |
commit | ec92f62650b73c4fe87f61f9e4b68246239fc017 (patch) | |
tree | 2e65cd4208e9a2e7a479bd2b9dc691a9e28e2b18 | |
parent | 3af91c3bf28a042b5ba08d085b3b4f1aefabb377 (diff) | |
parent | a562843a9b1e0a8eb70b68d871eeca6268173828 (diff) | |
download | prosody-ec92f62650b73c4fe87f61f9e4b68246239fc017.tar.gz prosody-ec92f62650b73c4fe87f61f9e4b68246239fc017.zip |
Automated merge with http://waqas.ath.cx:8000/
-rw-r--r-- | net/server.lua | 6 | ||||
-rw-r--r-- | plugins/mod_bosh.lua | 18 |
2 files changed, 17 insertions, 7 deletions
diff --git a/net/server.lua b/net/server.lua index a5c8e24c..cea2ada3 100644 --- a/net/server.lua +++ b/net/server.lua @@ -369,7 +369,9 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport end
bufferqueuelen = bufferqueuelen + 1
bufferqueue[ bufferqueuelen ] = data
- _writetimes[ handler ] = _writetimes[ handler ] or _currenttime
+ if handler then
+ _writetimes[ handler ] = _writetimes[ handler ] or _currenttime
+ end
return true
end
handler.write = write
@@ -470,7 +472,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport out_put( "server.lua: client ", ip, ":", clientport, " error: ", err )
fatalerror = true
disconnect( handler, err )
- handler.close( )
+ _ = handler and handler.close( )
return false
end
end
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 |