Skip to content

Commit

Permalink
Updated definition of whereis_name
Browse files Browse the repository at this point in the history
  • Loading branch information
Emile Joubert committed Dec 14, 2011
1 parent 0d3001e commit 28a7ad1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/gen_server2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ get_proc_name({local, Name}) ->
exit(process_not_registered)
end;
get_proc_name({global, Name}) ->
case global:whereis_name(Name) of
case whereis_name(Name) of
undefined ->
exit(process_not_registered_globally);
Pid when Pid =:= self() ->
Expand All @@ -1101,7 +1101,7 @@ get_parent() ->
name_to_pid(Name) ->
case whereis(Name) of
undefined ->
case global:whereis_name(Name) of
case whereis_name(Name) of
undefined ->
exit(could_not_find_registerd_name);
Pid ->
Expand All @@ -1111,6 +1111,20 @@ name_to_pid(Name) ->
Pid
end.

whereis_name(Name) ->
case ets:lookup(global_names, Name) of
[{_Name, Pid, _Method, _RPid, _Ref}] ->
if node(Pid) == node() ->
case is_process_alive(Pid) of
true -> Pid;
false -> undefined
end;
true ->
Pid
end;
[] -> undefined
end.

find_prioritisers(GS2State = #gs2_state { mod = Mod }) ->
PrioriCall = function_exported_or_default(
Mod, 'prioritise_call', 3,
Expand Down

0 comments on commit 28a7ad1

Please sign in to comment.