aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-12-17 18:59:29 +0000
committerMatthew Wild <mwild1@gmail.com>2009-12-17 18:59:29 +0000
commit07bddf1ea6f39a7b53c3acb39119c801abc4925d (patch)
treee8f73103b8383de06d8105a0c7ce2d937c54825f
parentb0055aa7b5f15e22bf9cd340f5f923eaa23a1d9f (diff)
downloadprosody-07bddf1ea6f39a7b53c3acb39119c801abc4925d.tar.gz
prosody-07bddf1ea6f39a7b53c3acb39119c801abc4925d.zip
s2smanager: Have both destroy_session and bounce_sendq accept a reason string to include in bounced stanzas
-rw-r--r--core/s2smanager.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index f4d46802..d60c20a1 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -51,7 +51,7 @@ module "s2smanager"
local function compare_srv_priorities(a,b) return a.priority < b.priority or a.weight < b.weight; end
-local function bounce_sendq(session)
+local function bounce_sendq(session, reason)
local sendq = session.sendq;
if sendq then
session.log("info", "sending error replies for "..#sendq.." queued stanzas because of failed outgoing connection to "..tostring(session.to_host));
@@ -69,6 +69,9 @@ local function bounce_sendq(session)
reply.attr.type = "error";
reply:tag("error", {type = "cancel"})
:tag("remote-server-not-found", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up();
+ if reason then
+ reply:tag("text", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):text("Connection failed: "..reason):up();
+ end
core_process_stanza(dummy, reply);
end
sendq[i] = nil;
@@ -483,12 +486,12 @@ function mark_connected(session)
end
end
-function destroy_session(session)
+function destroy_session(session, reason)
(session.log or log)("info", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host));
if session.direction == "outgoing" then
hosts[session.from_host].s2sout[session.to_host] = nil;
- bounce_sendq(session);
+ bounce_sendq(session, reason);
elseif session.direction == "incoming" then
incoming_s2s[session] = nil;
end