From 3df725786b93b54f681fd0baa3f004c0d961488a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 5 Jun 2011 11:48:57 +0100 Subject: mod_bosh: Mark a session as active when a request comes in, even if we don't end up holding that request, fixes BOSH ghosts (thanks smoku) --- plugins/mod_bosh.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua index a747f3cb..5ef6b18e 100644 --- a/plugins/mod_bosh.lua +++ b/plugins/mod_bosh.lua @@ -125,11 +125,11 @@ function handle_request(method, body, request) local session = sessions[request.sid]; if session then - -- Session was marked as inactive, since we have - -- a request open now, unmark it - if inactive_sessions[session] then - inactive_sessions[session] = nil; - end + -- Session was marked as inactive, since we have + -- a request open now, unmark it + if inactive_sessions[session] and #session.requests > 0 then + inactive_sessions[session] = nil; + end local r = session.requests; log("debug", "Session %s has %d out of %d requests open", request.sid, #r, session.bosh_hold); -- cgit v1.2.3 From 67088429be56260de6db1a75de036da082447d54 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 5 Jun 2011 11:53:29 +0100 Subject: mod_storage_sql: Fix commit c806a599224a for compatibility with non-MySQL databases (thanks Ognyan Kulev) --- plugins/mod_storage_sql.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index 57331ac0..055d6599 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -93,7 +93,7 @@ local function create_table() if not(ok and commit_ok) then module:log("warn", "Failed to create index (%s), lookups may not be optimised", err or commit_err); end - else -- COMPAT: Upgrade tables from 0.8.0 + elseif params.driver == "MySQL" then -- COMPAT: Upgrade tables from 0.8.0 -- Failed to create, but check existing MySQL table here local stmt = connection:prepare("SHOW COLUMNS FROM prosody WHERE Field='value' and Type='text'"); local ok = stmt:execute(); -- cgit v1.2.3 From b7ab106c4877b8c756a1c742183e057a037a3b0e Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 4 Mar 2011 20:27:57 +0000 Subject: mod_bosh: Fix terminate logic - process any stanzas in a terminating request, and add type='terminate' to any responses generated by those stanzas. Finally, close all remaining open requests with type='terminate' and close the session. Fixes #211 (thanks Maranda + waqas). --- plugins/mod_bosh.lua | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua index 5ef6b18e..a6b84367 100644 --- a/plugins/mod_bosh.lua +++ b/plugins/mod_bosh.lua @@ -162,7 +162,13 @@ function handle_request(method, body, request) end end - return true; -- Inform httpserver we shall reply later + if session.bosh_terminate then + session.log("debug", "Closing session with %d requests open", #session.requests); + session:close(); + return nil; + else + return true; -- Inform httpserver we shall reply later + end end end @@ -202,7 +208,6 @@ local function bosh_close_stream(session, reason) local session_close_response = { headers = default_headers, body = tostring(close_reply) }; - --FIXME: Quite sure we shouldn't reply to all requests with the error for _, held_request in ipairs(session.requests) do held_request:send(session_close_response); held_request:destroy(); @@ -255,7 +260,13 @@ function stream_callbacks.streamopened(request, attr) local oldest_request = r[1]; if oldest_request then log("debug", "We have an open request, so sending on that"); - response.body = t_concat{"", tostring(s), "" }; + response.body = t_concat({ + "", + tostring(s), + "" + }); oldest_request:send(response); --log("debug", "Sent"); if oldest_request.stayopen then @@ -327,13 +338,6 @@ function stream_callbacks.streamopened(request, attr) session.rid = rid; end - if attr.type == "terminate" then - -- Client wants to end this session - session:close(); - request.notopen = nil; - return; - end - if session.notopen then local features = st.stanza("stream:features"); hosts[session.host].events.fire_event("stream-features", { origin = session, features = features }); @@ -342,6 +346,12 @@ function stream_callbacks.streamopened(request, attr) session.notopen = nil; end + if attr.type == "terminate" then + -- Client wants to end this session, which we'll do + -- after processing any stanzas in this request + session.bosh_terminate = true; + end + request.notopen = nil; -- Signals that we accept this opening tag t_insert(session.requests, request); request.sid = sid; -- cgit v1.2.3 From 82639a7fbfbe2aaa3323024260acb029186381a4 Mon Sep 17 00:00:00 2001 From: Christian Haase Date: Sun, 5 Jun 2011 12:18:24 +0100 Subject: mod_groups: Persist changes to mod_groups contacts (e.g. moving groups) --- plugins/mod_groups.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_groups.lua b/plugins/mod_groups.lua index 7a876f1d..90c18fa1 100644 --- a/plugins/mod_groups.lua +++ b/plugins/mod_groups.lua @@ -34,9 +34,9 @@ function inject_roster_contacts(username, host, roster) end if not roster[jid].groups then roster[jid].groups = { [group_name] = true }; + roster[jid].persist = false; end roster[jid].groups[group_name] = true; - roster[jid].persist = false; end end end -- cgit v1.2.3 From 16a24fc55fa5027a2d4ae20ce8f086cb9c20849a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 5 Jun 2011 12:28:49 +0100 Subject: Backout commit d6366294f618 which I was testing and didn't mean to push to 0.8 --- plugins/mod_bosh.lua | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua index a6b84367..5ef6b18e 100644 --- a/plugins/mod_bosh.lua +++ b/plugins/mod_bosh.lua @@ -162,13 +162,7 @@ function handle_request(method, body, request) end end - if session.bosh_terminate then - session.log("debug", "Closing session with %d requests open", #session.requests); - session:close(); - return nil; - else - return true; -- Inform httpserver we shall reply later - end + return true; -- Inform httpserver we shall reply later end end @@ -208,6 +202,7 @@ local function bosh_close_stream(session, reason) local session_close_response = { headers = default_headers, body = tostring(close_reply) }; + --FIXME: Quite sure we shouldn't reply to all requests with the error for _, held_request in ipairs(session.requests) do held_request:send(session_close_response); held_request:destroy(); @@ -260,13 +255,7 @@ function stream_callbacks.streamopened(request, attr) local oldest_request = r[1]; if oldest_request then log("debug", "We have an open request, so sending on that"); - response.body = t_concat({ - "", - tostring(s), - "" - }); + response.body = t_concat{"", tostring(s), "" }; oldest_request:send(response); --log("debug", "Sent"); if oldest_request.stayopen then @@ -338,6 +327,13 @@ function stream_callbacks.streamopened(request, attr) session.rid = rid; end + if attr.type == "terminate" then + -- Client wants to end this session + session:close(); + request.notopen = nil; + return; + end + if session.notopen then local features = st.stanza("stream:features"); hosts[session.host].events.fire_event("stream-features", { origin = session, features = features }); @@ -346,12 +342,6 @@ function stream_callbacks.streamopened(request, attr) session.notopen = nil; end - if attr.type == "terminate" then - -- Client wants to end this session, which we'll do - -- after processing any stanzas in this request - session.bosh_terminate = true; - end - request.notopen = nil; -- Signals that we accept this opening tag t_insert(session.requests, request); request.sid = sid; -- cgit v1.2.3 From b761dbf8c31b0d272fe0005f7f40d281534a82e1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 6 Jun 2011 22:51:33 +0100 Subject: mod_dialback: More robust handling of multiple outstanding dialback requests for the same domain, fixes intermittent s2s with some (patched?) ejabberds --- plugins/mod_dialback.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index 8c80dce6..5060f08f 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -60,7 +60,7 @@ module:hook("stanza/jabber:server:dialback:result", function(event) return true; end - dialback_requests[attr.from] = origin; + dialback_requests[attr.from.."/"..origin.streamid] = origin; if not origin.from_host then -- Just used for friendlier logging @@ -83,8 +83,8 @@ module:hook("stanza/jabber:server:dialback:verify", function(event) if origin.type == "s2sout_unauthed" or origin.type == "s2sout" then local attr = stanza.attr; - local dialback_verifying = dialback_requests[attr.from]; - if dialback_verifying then + local dialback_verifying = dialback_requests[attr.from.."/"..(attr.id or "")]; + if dialback_verifying and attr.from == origin.to_host then local valid; if attr.type == "valid" then s2s_make_authenticated(dialback_verifying, attr.from); @@ -101,7 +101,7 @@ module:hook("stanza/jabber:server:dialback:verify", function(event) st.stanza("db:result", { from = attr.to, to = attr.from, id = attr.id, type = valid }) :text(dialback_verifying.hosts[attr.from].dialback_key)); end - dialback_requests[attr.from] = nil; + dialback_requests[attr.from.."/"..(attr.id or "")] = nil; end return true; end -- cgit v1.2.3 From 7c6db5e1b2d8579501981b1010574f0363330d28 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 7 Jun 2011 01:29:02 +0100 Subject: Backout bcdff2b1d3ec from 0.8 - going to commit a slightly cleaner patch for the same issue to trunk --- plugins/mod_groups.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_groups.lua b/plugins/mod_groups.lua index 90c18fa1..7a876f1d 100644 --- a/plugins/mod_groups.lua +++ b/plugins/mod_groups.lua @@ -34,9 +34,9 @@ function inject_roster_contacts(username, host, roster) end if not roster[jid].groups then roster[jid].groups = { [group_name] = true }; - roster[jid].persist = false; end roster[jid].groups[group_name] = true; + roster[jid].persist = false; end end end -- cgit v1.2.3