# HG changeset patch # User Matthew Wild # Date 1235049234 0 # Node ID e0197798f5f39138a72100e3f42498fb270bf037 # Parent a82eadc415ff9701ec1a0d1378f58d25f22c6dac# Parent 606fb325d7882bfef36ebafb8c8b0c2261f7551e Automated merge with http://waqas.ath.cx:8000/ diff -r a82eadc415ff -r e0197798f5f3 net/server.lua --- a/net/server.lua Thu Feb 19 14:10:26 2009 +0500 +++ b/net/server.lua Thu Feb 19 13:13:54 2009 +0000 @@ -369,7 +369,9 @@ 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 @@ 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 -r a82eadc415ff -r e0197798f5f3 plugins/mod_bosh.lua --- a/plugins/mod_bosh.lua Thu Feb 19 14:10:26 2009 +0500 +++ b/plugins/mod_bosh.lua Thu Feb 19 13:13:54 2009 +0000 @@ -32,6 +32,19 @@ 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 @@ 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 @@ (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