# HG changeset patch # User Matthew Wild # Date 1343046686 -3600 # Node ID 29bdf68ad142ca10dfa2ff49aaa8ce5eb1af5640 # Parent d37f2abac72c7f0890d8b6c2b36fa6667308f90e mod_s2s: Adjust session:close() in line with mod_c2s's - fixes waiting for if it has already been sent by the peer diff -r d37f2abac72c -r 29bdf68ad142 plugins/mod_s2s/mod_s2s.lua --- a/plugins/mod_s2s/mod_s2s.lua Mon Jul 23 13:29:33 2012 +0100 +++ b/plugins/mod_s2s/mod_s2s.lua Mon Jul 23 13:31:26 2012 +0100 @@ -290,7 +290,7 @@ function stream_callbacks.streamclosed(session) (session.log or log)("debug", "Received "); - session:close(); + session:close(false); end function stream_callbacks.error(session, error, data) @@ -342,7 +342,7 @@ session.sends2s(""); session.sends2s(st.stanza("stream:stream", default_stream_attr):top_tag()); end - if reason then + if reason then -- nil == no err, initiated by us, false == initiated by remote if type(reason) == "string" then -- assume stream error log("info", "Disconnecting %s[%s], is: %s", session.host or "(unknown host)", session.type, reason); session.sends2s(st.stanza("stream:error"):tag(reason, {xmlns = 'urn:ietf:params:xml:ns:xmpp-streams' })); @@ -363,16 +363,16 @@ end end end + session.sends2s(""); - function session.sends2s() return false; end - local reason = remote_reason or (reason and (reason.text or reason.condition)) or reason or "stream closed"; - session.log("info", "%s s2s stream %s->%s closed: %s", session.direction, session.from_host or "(unknown host)", session.to_host or "(unknown host)", reason); + local reason = remote_reason or (reason and (reason.text or reason.condition)) or reason; + session.log("info", "%s s2s stream %s->%s closed: %s", session.direction, session.from_host or "(unknown host)", session.to_host or "(unknown host)", reason or "stream closed"); -- Authenticated incoming stream may still be sending us stanzas, so wait for from remote local conn = session.conn; - if not session.notopen and session.type == "s2sin" then + if reason == nil and not session.notopen and session.type == "s2sin" then add_task(stream_close_timeout, function () if not session.destroyed then session.log("warn", "Failed to receive a stream close response, closing connection anyway...");