Comparison

plugins/mod_s2s/mod_s2s.lua @ 5274:0d08c0965824

mod_s2s: Remove connection from sessions table as soon as we learn it is disconnected. Fixes a connection/session leak.
author Matthew Wild <mwild1@gmail.com>
date Fri, 28 Dec 2012 12:47:44 +0000
parent 5173:b22d24b5a89a
child 5281:815c689f85ad
comparison
equal deleted inserted replaced
5272:1e555909f23d 5274:0d08c0965824
483 end 483 end
484 484
485 function listener.ondisconnect(conn, err) 485 function listener.ondisconnect(conn, err)
486 local session = sessions[conn]; 486 local session = sessions[conn];
487 if session then 487 if session then
488 sessions[conn] = nil;
488 if err and session.direction == "outgoing" and session.notopen then 489 if err and session.direction == "outgoing" and session.notopen then
489 (session.log or log)("debug", "s2s connection attempt failed: %s", err); 490 (session.log or log)("debug", "s2s connection attempt failed: %s", err);
490 if s2sout.attempt_connection(session, err) then 491 if s2sout.attempt_connection(session, err) then
491 (session.log or log)("debug", "...so we're going to try another target"); 492 (session.log or log)("debug", "...so we're going to try another target");
492 return; -- Session lives for now 493 return; -- Session lives for now
493 end 494 end
494 end 495 end
495 (session.log or log)("debug", "s2s disconnected: %s->%s (%s)", tostring(session.from_host), tostring(session.to_host), tostring(err or "connection closed")); 496 (session.log or log)("debug", "s2s disconnected: %s->%s (%s)", tostring(session.from_host), tostring(session.to_host), tostring(err or "connection closed"));
496 s2s_destroy_session(session, err); 497 s2s_destroy_session(session, err);
497 sessions[conn] = nil;
498 end 498 end
499 end 499 end
500 500
501 function listener.register_outgoing(conn, session) 501 function listener.register_outgoing(conn, session)
502 session.direction = "outgoing"; 502 session.direction = "outgoing";