Software /
code /
prosody
Comparison
plugins/s2s/mod_s2s.lua @ 4572:aba47e6dff43
mod_s2s: prevent attempting to reconnect when the stream is gracefully closed and fix TB by checking session.conn is set (racy racy?)
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Fri, 24 Feb 2012 15:36:36 +0000 |
parent | 4570:9612abc89dd1 |
child | 4573:09255a10fdfa |
child | 4574:4c24bb949e73 |
comparison
equal
deleted
inserted
replaced
4571:32d532b95dc7 | 4572:aba47e6dff43 |
---|---|
245 (session.log or log)("debug", "Received </stream:stream>"); | 245 (session.log or log)("debug", "Received </stream:stream>"); |
246 session:close(); | 246 session:close(); |
247 end | 247 end |
248 | 248 |
249 function stream_callbacks.streamdisconnected(session, err) | 249 function stream_callbacks.streamdisconnected(session, err) |
250 if err and err ~= "closed" then | 250 if err and err ~= "stream closed" then |
251 (session.log or log)("debug", "s2s connection attempt failed: %s", err); | 251 (session.log or log)("debug", "s2s connection attempt failed: %s", err); |
252 if s2sout.attempt_connection(session, err) then | 252 if s2sout.attempt_connection(session, err) then |
253 (session.log or log)("debug", "...so we're going to try another target"); | 253 (session.log or log)("debug", "...so we're going to try another target"); |
254 return true; -- Session lives for now | 254 return true; -- Session lives for now |
255 end | 255 end |
256 end | 256 end |
257 (session.log or log)("info", "s2s disconnected: %s->%s (%s)", tostring(session.from_host), tostring(session.to_host), tostring(err or "closed")); | 257 (session.log or log)("info", "s2s disconnected: %s->%s (%s)", tostring(session.from_host), tostring(session.to_host), tostring(err or "closed")); |
258 sessions[session.conn] = nil; | 258 if session.con then sessions[session.conn] = nil; else (session.log or log)("debug", "stale session's connection already closed"); end |
259 s2s_destroy_session(session, err); | 259 s2s_destroy_session(session, err); |
260 end | 260 end |
261 | 261 |
262 function stream_callbacks.error(session, error, data) | 262 function stream_callbacks.error(session, error, data) |
263 if error == "no-stream" then | 263 if error == "no-stream" then |