diff options
author | Mickaël Rémond <mickael.remond@process-one.net> | 2007-08-08 09:48:41 +0000 |
---|---|---|
committer | Mickaël Rémond <mickael.remond@process-one.net> | 2007-08-08 09:48:41 +0000 |
commit | 4e82569bcbcf828597c3a47716b4172c96994757 (patch) | |
tree | 672c503db6ce9a5fcb885f444f87a86f4bcb6368 | |
parent | * src/mod_offline.erl: Started implementation of mod_offline (diff) |
* 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
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/mod_offline.erl | 11 | ||||
-rw-r--r-- | src/p1_mnesia.erl | 4 |
3 files changed, 16 insertions, 5 deletions
@@ -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> * src/mod_offline.erl: Started implementation of mod_offline diff --git a/src/mod_offline.erl b/src/mod_offline.erl index 96d963fa3..303fe238f 100644 --- a/src/mod_offline.erl +++ b/src/mod_offline.erl @@ -59,9 +59,14 @@ loop() -> Msgs = receive_all(US, [Msg]), Len = length(Msgs), F = fun() -> - Count = Len + p1_mnesia:count_records( - offline_msg, - #offline_msg{us=US, _='_'}), + %% Only count messages if needed: + Count = if ?MAX_OFFLINE_MSGS == infinity -> + Len + p1_mnesia:count_records( + offline_msg, + #offline_msg{us=US, _='_'}); + true -> + 0 + end, if Count > ?MAX_OFFLINE_MSGS -> %% TODO: Warn that messages have been discarded diff --git a/src/p1_mnesia.erl b/src/p1_mnesia.erl index 2483a1b3f..3352e2d75 100644 --- a/src/p1_mnesia.erl +++ b/src/p1_mnesia.erl @@ -26,9 +26,9 @@ %% getting the record by small increment and by using continuation. -define(BATCHSIZE, 100). 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. - case mnesia:select(Tab, [{MatchExpression, [], [a]}], ?BATCHSIZE, read) of + case mnesia:select(Tab, [{MatchExpression, [], [[]]}], ?BATCHSIZE, read) of {Result,Cont} -> Count = length(Result), count_records_cont(Cont, Count); |