From e039c90768ea78e9deed108b72702dba49ef0302 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Wed, 20 Aug 2014 11:53:23 +0100 Subject: Fix a race. --- src/pg_local.erl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pg_local.erl b/src/pg_local.erl index dc6401ca..4d9914d9 100644 --- a/src/pg_local.erl +++ b/src/pg_local.erl @@ -84,7 +84,13 @@ get_members(Name) -> in_group(Name, Pid) -> ensure_started(), - member_present(Name, Pid). + %% The join message is a cast and thus can race, but we want to + %% keep it that way to be fast in the common case. + case member_present(Name, Pid) of + true -> true; + false -> sync(), + member_present(Name, Pid) + end. sync() -> ensure_started(), -- cgit v1.2.1