summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-06-11 17:14:08 +0100
committerSimon MacMullen <simon@rabbitmq.com>2014-06-11 17:14:08 +0100
commitc6e87d2ef84b1d16072581a0580974655a86afa3 (patch)
tree0fa68f6e325657d0dd6db283b39a065044bd053d
parent7f185eb6544d440181a3c9f386c520c329842d0a (diff)
parent5946cf4a8bc043e2a829463415a8243a10836223 (diff)
downloadrabbitmq-server-c6e87d2ef84b1d16072581a0580974655a86afa3.tar.gz
Merge bug26236
-rw-r--r--src/truncate.erl10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/truncate.erl b/src/truncate.erl
index 3ead6f38..820af1bf 100644
--- a/src/truncate.erl
+++ b/src/truncate.erl
@@ -102,17 +102,17 @@ term_limit(Thing, Max) ->
term_size(B, M, _W) when is_bitstring(B) -> lim(M, size(B));
term_size(A, M, W) when is_atom(A) -> lim(M, 2 * W);
term_size(N, M, W) when is_number(N) -> lim(M, 2 * W);
-term_size(F, M, W) when is_function(F) -> lim(M, erts_debug:flat_size(F) * W);
-term_size(P, M, W) when is_pid(P) -> lim(M, erts_debug:flat_size(P) * W);
term_size(T, M, W) when is_tuple(T) -> tuple_term_size(
T, M, 1, tuple_size(T), W);
-term_size([], M, _W) ->
+term_size([], M, _W) ->
M;
term_size([H|T], M, W) ->
case term_size(H, M, W) of
limit_exceeded -> limit_exceeded;
M2 -> lim(term_size(T, M2, W), 2 * W)
- end.
+ end;
+term_size(X, M, W) ->
+ lim(M, erts_debug:flat_size(X) * W).
lim(S, T) when is_number(S) andalso S > T -> S - T;
lim(_, _) -> limit_exceeded.
@@ -156,6 +156,8 @@ test_short_examples_exactly() ->
P = spawn(fun() -> receive die -> ok end end),
F([0, 0.0, <<1:1>>, F, P], [0, 0.0, <<1:1>>, F, P]),
P ! die,
+ R = make_ref(),
+ F([R], [R]),
ok.
test_term_limit() ->