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>
* src/mod_configure.erl: Bugfix: Show only virtual host users

View File

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

View File

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