25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

* src/ejabberd_sm.erl: Optimized check_max_sessions (thanks to

Christophe Romain)

SVN Revision: 975
This commit is contained in:
Alexey Shchepin 2007-11-25 15:35:20 +00:00
parent 1415fa4b1c
commit 65a7bb7d2a
2 changed files with 14 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2007-11-25 Alexey Shchepin <alexey@process-one.net>
* src/ejabberd_sm.erl: Optimized check_max_sessions (thanks to
Christophe Romain)
2007-11-22 Mickael Remond <mremond@process-one.net>
* src/ejabberd_config.erl: Improved error message when ejabberd

View File

@ -540,13 +540,16 @@ check_existing_resources(LUser, LServer, LResource) ->
check_max_sessions(LUser, LServer) ->
%% If the max number of sessions for a given is reached, we replace the
%% first one
SIDs = mnesia:dirty_select(
session,
[{#session{sid = '$1', usr = {LUser, LServer, '_'}, _ = '_'}, [], ['$1']}]),
SIDs = mnesia:dirty_select(
session,
[{#session{us = {LUser, LServer}, _ = '_'}, [], [[]]}]),
MaxSessions = get_max_user_sessions(LUser, LServer),
if length(SIDs) =< MaxSessions -> ok;
true -> {_, Pid} = lists:min(SIDs),
Pid ! replaced
if
length(SIDs) =< MaxSessions ->
ok;
true ->
{_, Pid} = lists:min(SIDs),
Pid ! replaced
end.