aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-05-17 11:49:24 +0100
committerMatthew Wild <mwild1@gmail.com>2010-05-17 11:49:24 +0100
commit95e01d796f994eb9ffcb902b38dd1c17ca7c4c57 (patch)
treeadb0617559793e0ba8c70c3c895ce455ba799c8b /plugins
parent2eb914de98a14c237f09e69b21d63d7f636f3def (diff)
downloadprosody-95e01d796f994eb9ffcb902b38dd1c17ca7c4c57.tar.gz
prosody-95e01d796f994eb9ffcb902b38dd1c17ca7c4c57.zip
mod_bosh: Always give requests a destroy handler, so that the management of each session's request array and the inactive_sessions logic can happen in one place. Simplifies everything and concludes this series of BOSH fixes.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_bosh.lua28
1 files changed, 15 insertions, 13 deletions
diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua
index ecce93cd..04887c29 100644
--- a/plugins/mod_bosh.lua
+++ b/plugins/mod_bosh.lua
@@ -73,6 +73,8 @@ function handle_request(method, body, request)
--log("debug", "Handling new request %s: %s\n----------", request.id, tostring(body));
request.notopen = true;
request.log = log;
+ request.on_destroy = on_destroy_request;
+
local parser = lxp.new(init_xmlhandlers(request, stream_callbacks), "\1");
parser:parse(body);
@@ -101,14 +103,21 @@ function handle_request(method, body, request)
session.send(resp);
end
- if not request.destroyed and session.bosh_wait then
- request.reply_before = os_time() + session.bosh_wait;
- request.on_destroy = on_destroy_request;
- waiting_requests[request] = true;
+ if not request.destroyed then
+ -- We're keeping this request open, to respond later
+ log("debug", "Have nothing to say, so leaving request unanswered for now");
+ if session.bosh_wait then
+ request.reply_before = os_time() + session.bosh_wait;
+ waiting_requests[request] = true;
+ end
+ if inactive_sessions[session] then
+ -- Session was marked as inactive, since we have
+ -- a request open now, unmark it
+ inactive_sessions[session] = nil;
+ end
end
- log("debug", "Have nothing to say, so leaving request unanswered for now");
- return true;
+ return true; -- Inform httpserver we shall reply later
end
end
@@ -171,7 +180,6 @@ function stream_callbacks.streamopened(request, attr)
else
log("debug", "Destroying the request now...");
oldest_request:destroy();
- t_remove(r, 1);
end
elseif s ~= "" then
log("debug", "Saved to send buffer because there are %d open requests", #r);
@@ -228,12 +236,6 @@ function stream_callbacks.streamopened(request, attr)
return;
end
- -- If session was inactive, make sure it is now marked as not
- if #session.requests == 0 then
- (session.log or log)("debug", "BOSH client now active again at %d", os_time());
- inactive_sessions[session] = nil;
- end
-
if session.notopen then
local features = st.stanza("stream:features");
fire_event("stream-features", session, features);