aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--src/mod_offline.erl11
-rw-r--r--src/p1_mnesia.erl4
3 files changed, 16 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index fe15038c5..e09de808d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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);