diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mod_offline.erl | 11 | ||||
-rw-r--r-- | src/p1_mnesia.erl | 4 |
2 files changed, 10 insertions, 5 deletions
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); |