25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

* src/ejabberd_s2s_out.erl: Make s2s connections more robust

* src/ejabberd_s2s.erl: Likewise

SVN Revision: 817
This commit is contained in:
Mickaël Rémond 2007-07-18 16:26:50 +00:00
parent dcf883005d
commit abadd82c66
3 changed files with 24 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2007-07-18 Mickael Remond <mickael.remond@process-one.net>
* src/ejabberd_s2s_out.erl: Make s2s connections more robust
* src/ejabberd_s2s.erl: Likewise
2007-07-17 Mickael Remond <mickael.remond@process-one.net> 2007-07-17 Mickael Remond <mickael.remond@process-one.net>
* src/mod_configure.erl: Bugfix: Show only virtual host users * src/mod_configure.erl: Bugfix: Show only virtual host users

View File

@ -61,12 +61,17 @@ remove_connection(FromTo) ->
mnesia:transaction(F). mnesia:transaction(F).
remove_connection(FromTo, Pid, Key) -> remove_connection(FromTo, Pid, Key) ->
F = fun() -> case catch mnesia:dirty_read(s2s, FromTo) of
mnesia:delete_object(#s2s{fromto = FromTo, [#s2s{pid = Pid, key = Key}] ->
pid = Pid, F = fun() ->
key = Key}) mnesia:delete_object(#s2s{fromto = FromTo,
end, pid = Pid,
mnesia:transaction(F). key = Key})
end,
mnesia:transaction(F);
_ ->
ok
end.
have_connection(FromTo) -> have_connection(FromTo) ->
case catch mnesia:dirty_read(s2s, FromTo) of case catch mnesia:dirty_read(s2s, FromTo) of
@ -262,7 +267,7 @@ find_connection(From, To) ->
{atomic, Pid} -> {atomic, Pid} ->
ejabberd_s2s_out:start_connection(Pid); ejabberd_s2s_out:start_connection(Pid);
_ -> _ ->
ok ejabberd_s2s_out:stop_connection(Pid)
end, end,
TRes TRes
end; end;

View File

@ -13,7 +13,8 @@
%% External exports %% External exports
-export([start/3, -export([start/3,
start_link/3, start_link/3,
start_connection/1]). start_connection/1,
stop_connection/1]).
%% gen_fsm callbacks %% gen_fsm callbacks
-export([init/1, -export([init/1,
@ -89,6 +90,9 @@ start_link(From, Host, Type) ->
start_connection(Pid) -> start_connection(Pid) ->
gen_fsm:send_event(Pid, init). gen_fsm:send_event(Pid, init).
stop_connection(Pid) ->
gen_fsm:send_event(Pid, stop).
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% Callback functions from gen_fsm %%% Callback functions from gen_fsm
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
@ -175,6 +179,8 @@ open_socket(init, StateData) ->
bounce_messages(Error), bounce_messages(Error),
{stop, normal, StateData} {stop, normal, StateData}
end; end;
open_socket(stop, StateData) ->
{stop, normal, StateData};
open_socket(_, StateData) -> open_socket(_, StateData) ->
{next_state, open_socket, StateData}. {next_state, open_socket, StateData}.