# HG changeset patch # User Matthew Wild # Date 1261076369 0 # Node ID 4726cd9a631869ca2e96116d2519da133900d724 # Parent 22dc9005360f124fc874edd064866390304e7aa6 s2smanager: Have both destroy_session and bounce_sendq accept a reason string to include in bounced stanzas diff -r 22dc9005360f -r 4726cd9a6318 core/s2smanager.lua --- a/core/s2smanager.lua Thu Dec 17 16:53:28 2009 +0000 +++ b/core/s2smanager.lua Thu Dec 17 18:59:29 2009 +0000 @@ -51,7 +51,7 @@ 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 @@ 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 @@ 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