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

* src/mod_offline.erl: Only count messages if a quota has been

actually set (EJAB-314).
* src/p1_mnesia.erl: Minor coding style change.

SVN Revision: 860
This commit is contained in:
Mickaël Rémond 2007-08-08 09:48:41 +00:00
parent 9d03ea3f98
commit 4e82569bcb
3 changed files with 16 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2007-08-08 Mickael Remond <mickael.remond@process-one.net>
* src/mod_offline.erl: Only count messages if a quota has been
actually set (EJAB-314).
* src/p1_mnesia.erl: Minor coding style change.
2007-08-07 Mickael Remond <mickael.remond@process-one.net> 2007-08-07 Mickael Remond <mickael.remond@process-one.net>
* src/mod_offline.erl: Started implementation of mod_offline * src/mod_offline.erl: Started implementation of mod_offline

View File

@ -59,9 +59,14 @@ loop() ->
Msgs = receive_all(US, [Msg]), Msgs = receive_all(US, [Msg]),
Len = length(Msgs), Len = length(Msgs),
F = fun() -> F = fun() ->
Count = Len + p1_mnesia:count_records( %% Only count messages if needed:
offline_msg, Count = if ?MAX_OFFLINE_MSGS == infinity ->
#offline_msg{us=US, _='_'}), Len + p1_mnesia:count_records(
offline_msg,
#offline_msg{us=US, _='_'});
true ->
0
end,
if if
Count > ?MAX_OFFLINE_MSGS -> Count > ?MAX_OFFLINE_MSGS ->
%% TODO: Warn that messages have been discarded %% TODO: Warn that messages have been discarded

View File

@ -26,9 +26,9 @@
%% getting the record by small increment and by using continuation. %% getting the record by small increment and by using continuation.
-define(BATCHSIZE, 100). -define(BATCHSIZE, 100).
count_records(Tab, MatchExpression) -> count_records(Tab, MatchExpression) ->
%% the result contains the atom a for each match: We do not need %% the result contains list of [] for each match: We do not need
%% actual values as we only count the data. %% actual values as we only count the data.
case mnesia:select(Tab, [{MatchExpression, [], [a]}], ?BATCHSIZE, read) of case mnesia:select(Tab, [{MatchExpression, [], [[]]}], ?BATCHSIZE, read) of
{Result,Cont} -> {Result,Cont} ->
Count = length(Result), Count = length(Result),
count_records_cont(Cont, Count); count_records_cont(Cont, Count);