diff options
author | Emile Joubert <emile@rabbitmq.com> | 2011-12-12 14:02:38 +0000 |
---|---|---|
committer | Emile Joubert <emile@rabbitmq.com> | 2011-12-12 14:02:38 +0000 |
commit | 09ebd2a554e82f70f7c1543583f1e4d8cf82401e (patch) | |
tree | b580aed1d9ee736bf148213dbfc4e063e71be88f | |
parent | 93dc0426c2677e2456378100afd4d62a6b0b78e4 (diff) | |
download | rabbitmq-server-09ebd2a554e82f70f7c1543583f1e4d8cf82401e.tar.gz |
remove rabbit dependencies from gm
-rw-r--r-- | src/gm.erl | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -386,6 +386,7 @@ -define(HIBERNATE_AFTER_MIN, 1000). -define(DESIRED_HIBERNATE, 10000). -define(BROADCAST_TIMER, 25). +-define(VERSION_START, 0). -define(SETS, ordsets). -define(DICT, orddict). @@ -515,7 +516,7 @@ group_members(Server) -> init([GroupName, Module, Args]) -> {MegaSecs, Secs, MicroSecs} = now(), random:seed(MegaSecs, Secs, MicroSecs), - Self = make_member(self()), + Self = make_member(GroupName), gen_server2:cast(self(), join), {ok, #state { self = Self, left = {Self, undefined}, @@ -1007,7 +1008,7 @@ prune_or_create_group(Self, GroupName) -> mnesia:sync_transaction( fun () -> GroupNew = #gm_group { name = GroupName, members = [Self], - version = 0 }, + version = ?VERSION_START }, case mnesia:read({?GROUP_TABLE, GroupName}) of [] -> mnesia:write(GroupNew), @@ -1241,11 +1242,15 @@ prepare_members_state(MembersState) -> build_members_state(MembersStateList) -> ?DICT:from_list(MembersStateList). -make_member(Pid) -> {rabbit_guid:guid(), Pid}. +make_member(GroupName) -> + {case read_group(GroupName) of + #gm_group { version = Version } -> Version; + {error, not_found} -> ?VERSION_START + end, self()}. -get_pid({_Guid, Pid}) -> Pid. +get_pid({_Version, Pid}) -> Pid. -get_pids(Ids) -> [Pid || {_Guid, Pid} <- Ids]. +get_pids(Ids) -> [Pid || {_Version, Pid} <- Ids]. %% --------------------------------------------------------------------------- %% Activity assembly |