From c8c7169465e7a86b1f89f984811b19c91747b8f6 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Thu, 4 Mar 2010 12:43:43 +0900 Subject: [PATCH] improved s2s connections clean up (EJAB-1202) --- src/ejabberd_s2s_out.erl | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/ejabberd_s2s_out.erl b/src/ejabberd_s2s_out.erl index f53a4e727..1b0b8a78b 100644 --- a/src/ejabberd_s2s_out.erl +++ b/src/ejabberd_s2s_out.erl @@ -910,21 +910,28 @@ send_db_request(StateData) -> Key -> Key end, - case New of - false -> - ok; - Key1 -> - send_element(StateData, exmpp_dialback:key( - StateData#state.myname, Server, Key1)) - end, - case StateData#state.verify of - false -> - ok; - {_Pid, Key2, SID} -> - send_element(StateData, exmpp_dialback:verify_request( - StateData#state.myname, StateData#state.server, SID, Key2)) - end, - {next_state, wait_for_validation, StateData#state{new = New}, ?FSMTIMEOUT*6}. + NewStateData = StateData#state{new = New}, + try + case New of + false -> + ok; + Key1 -> + send_element(StateData, exmpp_dialback:key( + StateData#state.myname, Server, Key1)) + end, + case StateData#state.verify of + false -> + ok; + {_Pid, Key2, SID} -> + send_element(StateData, exmpp_dialback:verify_request( + StateData#state.myname, + StateData#state.server, SID, Key2)) + end, + {next_state, wait_for_validation, NewStateData, ?FSMTIMEOUT*6} + catch + _:_ -> + {stop, normal, NewStateData} + end. is_verify_res(#xmlel{ns = ?NS_DIALBACK, name = 'result',