summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2013-04-18 20:45:44 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2013-04-18 20:45:44 +0100
commit482615b416f96b28265f2e3c91f6689690565229 (patch)
tree0c1e3129908d82b45c8898ea007591e2b0d8d2fc /src
parent8a29dba37b9c2253eed0b4b1d864d367c086bd4c (diff)
downloadrabbitmq-server-git-482615b416f96b28265f2e3c91f6689690565229.tar.gz
include the named processes in the sums
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_vm.erl45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/rabbit_vm.erl b/src/rabbit_vm.erl
index d09b1c9d4a..f3508cae1e 100644
--- a/src/rabbit_vm.erl
+++ b/src/rabbit_vm.erl
@@ -149,30 +149,37 @@ sum_processes(Names, Fun, Acc0) ->
Acc0Dict = orddict:from_list(Acc0),
NameAccs0 = orddict:from_list([{Name, Acc0Dict} || Name <- Names]),
{NameAccs, OtherAcc} =
- lists:foldl(fun (Pid, Acc) ->
- case process_info(Pid, [dictionary | Items]) of
- undefined ->
- Acc;
- [{dictionary, D} | Vals] ->
- ValsDict = orddict:from_list(Vals),
- accumulate(find_ancestor(D, Names), Fun,
- ValsDict, Acc)
- end
- end, {NameAccs0, Acc0Dict}, processes()),
+ lists:foldl(
+ fun (Pid, Acc) ->
+ InfoItems = [registered_name, dictionary | Items],
+ case process_info(Pid, InfoItems) of
+ undefined ->
+ Acc;
+ [{registered_name, RegName}, {dictionary, D} | Vals] ->
+ %% see docs for process_info/2 for the
+ %% special handling of 'registered_name'
+ %% info items
+ Extra = case RegName of
+ [] -> [];
+ N -> [N]
+ end,
+ accumulate(find_ancestor(Extra, D, Names), Fun,
+ orddict:from_list(Vals), Acc)
+ end
+ end, {NameAccs0, Acc0Dict}, processes()),
%% these conversions aren't strictly necessary; we do them simply
%% for the sake of encapsulating the representation.
{[orddict:to_list(NameAcc) || NameAcc <- orddict:to_list(NameAccs)],
orddict:to_list(OtherAcc)}.
-find_ancestor(D, Names) ->
- case lists:keyfind('$ancestors', 1, D) of
- false -> undefined;
- {_, Ancestors} -> case lists:splitwith(
- fun (A) -> not lists:member(A, Names) end,
- Ancestors) of
- {_, []} -> undefined;
- {_, [Name | _]} -> Name
- end
+find_ancestor(Extra, D, Names) ->
+ case lists:splitwith(fun (A) -> not lists:member(A, Names) end,
+ Extra ++ case lists:keyfind('$ancestors', 1, D) of
+ false -> [];
+ {_, Ancestors} -> Ancestors
+ end) of
+ {_, []} -> undefined;
+ {_, [Name | _]} -> Name
end.
accumulate(undefined, Fun, ValsDict, {NameAccs, OtherAcc}) ->