aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/pg2.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2010-01-07 12:33:01 +0000
committerErlang/OTP <[email protected]>2010-01-07 12:33:01 +0000
commit36c0041ea56d915ba9a2259cc918fca76b8c08f9 (patch)
tree780958eab055d0cc71d97a9120a808a17bfdc2f3 /lib/kernel/src/pg2.erl
parentfbdeb03d3919b096e039302801e2e865267a6943 (diff)
downloadotp-36c0041ea56d915ba9a2259cc918fca76b8c08f9.tar.gz
otp-36c0041ea56d915ba9a2259cc918fca76b8c08f9.tar.bz2
otp-36c0041ea56d915ba9a2259cc918fca76b8c08f9.zip
OTP-8358 A race bug affecting pg2:get_local_members/1 has been fixed. The
bug was introduced in R13B03.
Diffstat (limited to 'lib/kernel/src/pg2.erl')
-rw-r--r--lib/kernel/src/pg2.erl17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/kernel/src/pg2.erl b/lib/kernel/src/pg2.erl
index fc9508a194..cb9fec2ffe 100644
--- a/lib/kernel/src/pg2.erl
+++ b/lib/kernel/src/pg2.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(pg2).
@@ -334,8 +334,11 @@ local_group_members(Name) ->
P <- member_in_group(Pid, Name)].
member_in_group(Pid, Name) ->
- [{{member, Name, Pid}, N}] = ets:lookup(pg2_table, {member, Name, Pid}),
- lists:duplicate(N, Pid).
+ case ets:lookup(pg2_table, {member, Name, Pid}) of
+ [] -> [];
+ [{{member, Name, Pid}, N}] ->
+ lists:duplicate(N, Pid)
+ end.
member_groups(Pid) ->
[Name || [Name] <- ets:match(pg2_table, {{pid, Pid, '$1'}})].