diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2012-11-29 12:51:21 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-11-29 12:51:21 +0000 |
| commit | df3f4861dde951e70323c01de9ee84c44d865601 (patch) | |
| tree | 54b16fc8d9b8e0fc1a52667d9bc43b67c770f256 | |
| parent | b6bcb05215c036c67b6724bc7d9c4ababf5ed034 (diff) | |
| download | rabbitmq-server-git-df3f4861dde951e70323c01de9ee84c44d865601.tar.gz | |
cosmetic, plus correctly identify provenance
| -rw-r--r-- | src/rabbit_misc.erl | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index cd83e3b88d..ccf3d8be45 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -1037,44 +1037,35 @@ interval_operation({M, F, A}, MaxRatio, IdealInterval, LastInterval) -> end}. %% ------------------------------------------------------------------------- -%% Begin copypasta from gen_server.erl +%% Begin copypasta from gen_server2.erl get_parent() -> case get('$ancestors') of - [Parent | _] when is_pid(Parent)-> - Parent; - [Parent | _] when is_atom(Parent)-> - name_to_pid(Parent); - _ -> - exit(process_was_not_started_by_proc_lib) + [Parent | _] when is_pid (Parent) -> Parent; + [Parent | _] when is_atom(Parent) -> name_to_pid(Parent); + _ -> exit(process_was_not_started_by_proc_lib) end. name_to_pid(Name) -> case whereis(Name) of - undefined -> - case whereis_name(Name) of - undefined -> - exit(could_not_find_registerd_name); - Pid -> - Pid - end; - Pid -> - Pid + undefined -> case whereis_name(Name) of + undefined -> exit(could_not_find_registerd_name); + Pid -> Pid + end; + Pid -> Pid end. whereis_name(Name) -> case ets:lookup(global_names, Name) of - [{_Name, Pid, _Method, _RPid, _Ref}] -> - if node(Pid) == node() -> - case erlang:is_process_alive(Pid) of - true -> Pid; - false -> undefined + [{_Name, Pid, _Method, _RPid, _Ref}] -> + if node(Pid) == node() -> case erlang:is_process_alive(Pid) of + true -> Pid; + false -> undefined + end; + true -> Pid end; - true -> - Pid - end; - [] -> undefined + [] -> undefined end. -%% End copypasta from gen_server.erl +%% End copypasta from gen_server2.erl %% ------------------------------------------------------------------------- |
