Browse Source

don't call is_process_alive on remote pids (thks sg2342)

Ulf Wiger 14 years ago
parent
commit
023e927268
7 changed files with 37 additions and 14 deletions
  1. 4 2
      doc/gproc.md
  2. 4 2
      doc/gproc_app.md
  3. 4 2
      doc/gproc_dist.md
  4. 3 1
      doc/gproc_init.md
  5. 3 1
      doc/gproc_lib.md
  6. 4 2
      doc/gproc_sup.md
  7. 15 4
      src/gproc.erl

+ 4 - 2
doc/gproc.md

@@ -8,11 +8,13 @@ Module gproc
 * [Data Types](#types)
 * [Function Index](#index)
 * [Function Details](#functions)
+
+
 Extended process registry.
 
 
 
-__Behaviours:__ [`gen_server`](gen_server.html).
+__Behaviours:__ [`gen_server`](gen_server.md).
 
 __Authors:__ Ulf Wiger ([`ulf.wiger@erlang-consulting.com`](mailto:ulf.wiger@erlang-consulting.com)).
 
@@ -884,4 +886,4 @@ The type of registration entry must be either name or aggregated counter.
 Otherwise this function will exit. Use [`lookup_pids/1`](#lookup_pids-1) in these
 cases.
 
-_Generated by EDoc, Oct 31 2010, 18:30:39._
+_Generated by EDoc, Nov 19 2010, 20:03:18._

+ 4 - 2
doc/gproc_app.md

@@ -10,7 +10,9 @@ Module gproc_app
 
 
 
-__Behaviours:__ [`application`](application.html).
+
+
+__Behaviours:__ [`application`](application.md).
 
 <h2><a name="index">Function Index</a></h2>
 
@@ -62,4 +64,4 @@ __Behaviours:__ [`application`](application.html).
 
 
 
-_Generated by EDoc, Oct 31 2010, 18:30:39._
+_Generated by EDoc, Nov 19 2010, 20:03:18._

+ 4 - 2
doc/gproc_dist.md

@@ -7,11 +7,13 @@ Module gproc_dist
 * [Description](#description)
 * [Function Index](#index)
 * [Function Details](#functions)
+
+
 Extended process registry.
 
 
 
-__Behaviours:__ [`gen_leader`](gen_leader.html).
+__Behaviours:__ [`gen_leader`](gen_leader.md).
 
 __Authors:__ Ulf Wiger ([`ulf.wiger@ericsson.com`](mailto:ulf.wiger@ericsson.com)).
 
@@ -327,4 +329,4 @@ Scope = l | g (global or local)
 
 
 
-_Generated by EDoc, Oct 31 2010, 18:30:39._
+_Generated by EDoc, Nov 19 2010, 20:03:18._

+ 3 - 1
doc/gproc_init.md

@@ -10,6 +10,8 @@ Module gproc_init
 
 
 
+
+
 <h2><a name="index">Function Index</a></h2>
 
 
@@ -48,4 +50,4 @@ Module gproc_init
 
 
 
-_Generated by EDoc, Oct 31 2010, 18:30:39._
+_Generated by EDoc, Nov 19 2010, 20:03:18._

+ 3 - 1
doc/gproc_lib.md

@@ -5,6 +5,8 @@ Module gproc_lib
 <h1>Module gproc_lib</h1>
 
 * [Description](#description)
+
+
 Extended process registry.
 
 
@@ -20,4 +22,4 @@ This module implements an extended process registry
 
 For a detailed description, see gproc/doc/erlang07-wiger.pdf.
 
-_Generated by EDoc, Oct 31 2010, 18:30:39._
+_Generated by EDoc, Nov 19 2010, 20:03:18._

+ 4 - 2
doc/gproc_sup.md

@@ -10,7 +10,9 @@ Module gproc_sup
 
 
 
-__Behaviours:__ [`supervisor`](supervisor.html).
+
+
+__Behaviours:__ [`supervisor`](supervisor.md).
 
 <h2><a name="index">Function Index</a></h2>
 
@@ -52,4 +54,4 @@ The main GPROC supervisor.
 
 
 
-_Generated by EDoc, Oct 31 2010, 18:30:39._
+_Generated by EDoc, Nov 19 2010, 20:03:18._

+ 15 - 4
src/gproc.erl

@@ -534,7 +534,7 @@ where({T,_,_}=Key) ->
     if T==n orelse T==a ->
             case ets:lookup(?TAB, {Key,T}) of
                 [{_, P, _Value}] ->
-                    case is_process_alive(P) of
+                    case my_is_process_alive(P) of
 			true -> P;
 			false ->
 			    undefined
@@ -561,8 +561,19 @@ lookup_pids({T,_,_} = Key) ->
 	   true ->
 		ets:select(?TAB, [{{{Key,'_'}, '$1', '_'},[],['$1']}])
 	end,
-    [P || P <- L, is_process_alive(P)].
-	  
+    [P || P <- L, my_is_process_alive(P)].
+
+
+%% @spec (pid()) -> boolean()
+%%
+my_is_process_alive(P) when node(P) =:= node() ->
+    is_process_alive(P);
+my_is_process_alive(_) ->
+    %% remote pid - assume true (too costly to find out)
+    true.
+
+
+
 
 %% @spec (Key::key()) -> [{pid(), Value}]
 %%
@@ -579,7 +590,7 @@ lookup_values({T,_,_} = Key) ->
 	   true ->
 		ets:select(?TAB, [{{{Key,'_'}, '$1', '$2'},[],[{{'$1','$2'}}]}])
 	end,
-    [Pair || {P,_} = Pair <- L, is_process_alive(P)].
+    [Pair || {P,_} = Pair <- L, my_is_process_alive(P)].