aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMickaël Rémond <mickael.remond@process-one.net>2007-09-14 14:19:48 +0000
committerMickaël Rémond <mickael.remond@process-one.net>2007-09-14 14:19:48 +0000
commitb3fb9d9100970dec4d00a9ed0cccd2be117b7450 (patch)
tree511a64899a0db8de95021ce1f1c3b511753b8ca0
parentIgnore more files in git. (diff)
Try to open all s2s connections at the same time, to guarantee the right order of the packets.
SVN Revision: 941
-rw-r--r--src/ejabberd_s2s.erl23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/ejabberd_s2s.erl b/src/ejabberd_s2s.erl
index 02a6c49d9..3836b685b 100644
--- a/src/ejabberd_s2s.erl
+++ b/src/ejabberd_s2s.erl
@@ -253,7 +253,14 @@ find_connection(From, To) ->
case {is_service(From, To),
allow_host(MyServer, Server)} of
{false, true} ->
- new_connection(MyServer, Server, From, FromTo, Max_S2S_Connexions_Number);
+ Connections_Result = [new_connection(MyServer, Server, From, FromTo, Max_S2S_Connexions_Number)
+ || _N <- lists:seq(1, Max_S2S_Connexions_Number)],
+ case [PID || {atomic, PID} <- Connections_Result] of
+ [] ->
+ hd(Connections_Result);
+ PIDs ->
+ {atomic, choose_connection(From, PIDs)}
+ end;
_ ->
{aborted, error}
end;
@@ -266,11 +273,17 @@ find_connection(From, To) ->
end.
choose_connection(From, Connections) ->
- % use sticky connections based on the full JID of the sender
- El = lists:nth(erlang:phash(From, length(Connections)), Connections),
%El = lists:nth(random:uniform(length(Connections)), Connections),
- ?ERROR_MSG("XXX using ejabberd_s2s_out ~p~n", [El#s2s.pid]),
- El#s2s.pid.
+ % use sticky connections based on the full JID of the sender
+ Pid = case lists:nth(erlang:phash(From, length(Connections)), Connections) of
+ El when is_record(El, s2s) ->
+ El#s2s.pid;
+ P when is_pid(P) ->
+ P
+ end,
+ ?ERROR_MSG("XXX using ejabberd_s2s_out ~p~n", [Pid]),
+ Pid.
+
new_connection(MyServer, Server, From, FromTo, Max_S2S_Connexions_Number) ->
Key = randoms:get_string(),