mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
* src/ejabberd_sm.erl: Optimized check_max_sessions (thanks to
Christophe Romain) SVN Revision: 975
This commit is contained in:
parent
1415fa4b1c
commit
65a7bb7d2a
@ -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
|
||||
|
@ -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.
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user