diff options
author | Matthew Sackman <matthew@rabbitmq.com> | 2011-04-01 17:29:24 +0100 |
---|---|---|
committer | Matthew Sackman <matthew@rabbitmq.com> | 2011-04-01 17:29:24 +0100 |
commit | d70cddd75bba6df1a4a6a549f2296bbbed828400 (patch) | |
tree | 4b61e35d7488896cdabfd8da2e405ff0011fdb10 | |
parent | 4c5f452226bad9d82ab3ad387d18a89262964307 (diff) | |
parent | e212ab7f5e8c84ed242d5e1b95cc1feefc102513 (diff) | |
download | rabbitmq-server-d70cddd75bba6df1a4a6a549f2296bbbed828400.tar.gz |
merging bug22952 to default
-rw-r--r-- | src/gm.erl | 11 | ||||
-rw-r--r-- | src/gm_soak_test.erl | 7 | ||||
-rw-r--r-- | src/rabbit_amqqueue_process.erl | 14 | ||||
-rw-r--r-- | src/rabbit_control.erl | 5 | ||||
-rw-r--r-- | src/rabbit_exchange_type_topic.erl | 8 |
5 files changed, 27 insertions, 18 deletions
@@ -516,7 +516,8 @@ flush(Server) -> init([GroupName, Module, Args]) -> - random:seed(now()), + {MegaSecs, Secs, MicroSecs} = now(), + random:seed(MegaSecs, Secs, MicroSecs), gen_server2:cast(self(), join), Self = self(), {ok, #state { self = Self, @@ -1010,7 +1011,7 @@ prune_or_create_group(Self, GroupName) -> fun () -> GroupNew = #gm_group { name = GroupName, members = [Self], version = 0 }, - case mnesia:read(?GROUP_TABLE, GroupName) of + case mnesia:read({?GROUP_TABLE, GroupName}) of [] -> mnesia:write(GroupNew), GroupNew; @@ -1028,7 +1029,7 @@ record_dead_member_in_group(Member, GroupName) -> {atomic, Group} = mnesia:sync_transaction( fun () -> [Group1 = #gm_group { members = Members, version = Ver }] = - mnesia:read(?GROUP_TABLE, GroupName), + mnesia:read({?GROUP_TABLE, GroupName}), case lists:splitwith( fun (Member1) -> Member1 =/= Member end, Members) of {_Members1, []} -> %% not found - already recorded dead @@ -1048,7 +1049,7 @@ record_new_member_in_group(GroupName, Left, NewMember, Fun) -> mnesia:sync_transaction( fun () -> [#gm_group { members = Members, version = Ver } = Group1] = - mnesia:read(?GROUP_TABLE, GroupName), + mnesia:read({?GROUP_TABLE, GroupName}), {Prefix, [Left | Suffix]} = lists:splitwith(fun (M) -> M =/= Left end, Members), Members1 = Prefix ++ [Left, NewMember | Suffix], @@ -1067,7 +1068,7 @@ erase_members_in_group(Members, GroupName) -> fun () -> [Group1 = #gm_group { members = [_|_] = Members1, version = Ver }] = - mnesia:read(?GROUP_TABLE, GroupName), + mnesia:read({?GROUP_TABLE, GroupName}), case Members1 -- DeadMembers of Members1 -> Group1; Members2 -> Group2 = diff --git a/src/gm_soak_test.erl b/src/gm_soak_test.erl index 1f8832a6..dae42ac7 100644 --- a/src/gm_soak_test.erl +++ b/src/gm_soak_test.erl @@ -35,7 +35,7 @@ with_state(Fun) -> inc() -> case 1 + get(count) of - 100000 -> Now = os:timestamp(), + 100000 -> Now = now(), Start = put(ts, Now), Diff = timer:now_diff(Now, Start), Rate = 100000 / (Diff / 1000000), @@ -48,7 +48,7 @@ joined([], Members) -> io:format("Joined ~p (~p members)~n", [self(), length(Members)]), put(state, dict:from_list([{Member, empty} || Member <- Members])), put(count, 0), - put(ts, os:timestamp()), + put(ts, now()), ok. members_changed([], Births, Deaths) -> @@ -101,7 +101,8 @@ terminate([], Reason) -> spawn_member() -> spawn_link( fun () -> - random:seed(now()), + {MegaSecs, Secs, MicroSecs} = now(), + random:seed(MegaSecs, Secs, MicroSecs), %% start up delay of no more than 10 seconds timer:sleep(random:uniform(10000)), {ok, Pid} = gm:start_link(?MODULE, ?MODULE, []), diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 3f5758ce..2b0fe17e 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -428,11 +428,19 @@ confirm_messages(MsgIds, State = #q{msg_id_to_channel = MTC}) -> {CMs, MTC0} end end, {gb_trees:empty(), MTC}, MsgIds), - gb_trees:map(fun(ChPid, MsgSeqNos) -> - rabbit_channel:confirm(ChPid, MsgSeqNos) - end, CMs), + gb_trees_foreach(fun(ChPid, MsgSeqNos) -> + rabbit_channel:confirm(ChPid, MsgSeqNos) + end, CMs), State#q{msg_id_to_channel = MTC1}. +gb_trees_foreach(_, none) -> + ok; +gb_trees_foreach(Fun, {Key, Val, It}) -> + Fun(Key, Val), + gb_trees_foreach(Fun, gb_trees:next(It)); +gb_trees_foreach(Fun, Tree) -> + gb_trees_foreach(Fun, gb_trees:next(gb_trees:iterator(Tree))). + gb_trees_cons(Key, Value, Tree) -> case gb_trees:lookup(Key, Tree) of {value, Values} -> gb_trees:update(Key, [Value | Values], Tree); diff --git a/src/rabbit_control.erl b/src/rabbit_control.erl index 6fb465b5..1af91f4c 100644 --- a/src/rabbit_control.erl +++ b/src/rabbit_control.erl @@ -304,10 +304,9 @@ action(list_permissions, Node, [], Opts, Inform) -> wait_for_application(Node, Attempts) -> case rpc_call(Node, application, which_applications, [infinity]) of - {badrpc, _} = E -> NewAttempts = Attempts - 1, - case NewAttempts of + {badrpc, _} = E -> case Attempts of 0 -> E; - _ -> wait_for_application0(Node, NewAttempts) + _ -> wait_for_application0(Node, Attempts - 1) end; Apps -> case proplists:is_defined(rabbit, Apps) of %% We've seen the node up; if it goes down diff --git a/src/rabbit_exchange_type_topic.erl b/src/rabbit_exchange_type_topic.erl index ffd1e583..c192f8cf 100644 --- a/src/rabbit_exchange_type_topic.erl +++ b/src/rabbit_exchange_type_topic.erl @@ -188,10 +188,10 @@ follow_down(X, CurNode, AccFun, Acc, Words = [W | RestW]) -> end. trie_child(X, Node, Word) -> - case mnesia:read(rabbit_topic_trie_edge, - #trie_edge{exchange_name = X, - node_id = Node, - word = Word}) of + case mnesia:read({rabbit_topic_trie_edge, + #trie_edge{exchange_name = X, + node_id = Node, + word = Word}}) of [#topic_trie_edge{node_id = NextNode}] -> {ok, NextNode}; [] -> error end. |