# HG changeset patch # User Matthew Wild # Date 1343044607 -3600 # Node ID 9da430b69f13542605c63c769d252df1fdb73e91 # Parent 0f72123ff513cd051053adea5ef9e8a6dcd5a2b8 mod_c2s: Change 'reason' parameter of session:close() to take nil to mean 'graceful close initiated by us' and false for 'graceful close initiated by client' diff -r 0f72123ff513 -r 9da430b69f13 plugins/mod_c2s.lua --- a/plugins/mod_c2s.lua Mon Jul 23 12:25:33 2012 +0100 +++ b/plugins/mod_c2s.lua Mon Jul 23 12:56:47 2012 +0100 @@ -76,7 +76,7 @@ function stream_callbacks.streamclosed(session) session.log("debug", "Received "); - session:close(); + session:close(false); end function stream_callbacks.error(session, error, data) @@ -122,7 +122,7 @@ session.send(""); session.send(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 client if type(reason) == "string" then -- assume stream error log("info", "Disconnecting client, is: %s", reason); session.send(st.stanza("stream:error"):tag(reason, {xmlns = 'urn:ietf:params:xml:ns:xmpp-streams' })); @@ -143,16 +143,16 @@ end end end + session.send(""); - function session.send() return false; end - local reason = (reason and (reason.text or reason.condition)) or reason or "session closed"; - session.log("info", "c2s stream for %s closed: %s", session.full_jid or ("<"..session.ip..">"), reason); + local reason = (reason and (reason.text or reason.condition)) or reason; + session.log("info", "c2s stream for %s closed: %s", session.full_jid or ("<"..session.ip..">"), reason or "session closed"); -- Authenticated incoming stream may still be sending us stanzas, so wait for from remote local conn = session.conn; - if reason == "session closed" and not session.notopen and session.type == "c2s" then + if reason == nil and not session.notopen and session.type == "c2s" then -- Grace time to process data from authenticated cleanly-closed stream add_task(stream_close_timeout, function () if not session.destroyed then