From 36c0041ea56d915ba9a2259cc918fca76b8c08f9 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Thu, 7 Jan 2010 12:33:01 +0000 Subject: OTP-8358 A race bug affecting pg2:get_local_members/1 has been fixed. The bug was introduced in R13B03. --- lib/kernel/src/pg2.erl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lib/kernel/src/pg2.erl') 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'}})]. -- cgit v1.2.3