diff options
| author | Matthew Sackman <matthew@lshift.net> | 2010-05-04 12:12:56 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2010-05-04 12:12:56 +0100 |
| commit | 7fcb224166ba0eeec3564bc0b6b01311fe552ebd (patch) | |
| tree | 1325cd7ed40d0ae67318f0e928299b73538b1d7f | |
| parent | 13291e27f56b107b1585d3937aad5ec16ea66d38 (diff) | |
| parent | a52a3b1f3eab0c9c558966cfa5704a3365441cb2 (diff) | |
| download | rabbitmq-server-git-7fcb224166ba0eeec3564bc0b6b01311fe552ebd.tar.gz | |
Merging bug 22671 onto default
| -rw-r--r-- | src/gen_server2.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_exchange.erl | 11 | ||||
| -rw-r--r-- | src/rabbit_misc.erl | 50 | ||||
| -rw-r--r-- | src/rabbit_persister.erl | 4 | ||||
| -rw-r--r-- | src/rabbit_router.erl | 15 |
5 files changed, 13 insertions, 69 deletions
diff --git a/src/gen_server2.erl b/src/gen_server2.erl index 94a23fb90a..5b899cdbc7 100644 --- a/src/gen_server2.erl +++ b/src/gen_server2.erl @@ -443,7 +443,7 @@ init_it(Starter, Parent, Name0, Mod, Args, Options) -> name({local,Name}) -> Name; name({global,Name}) -> Name; %% name(Pid) when is_pid(Pid) -> Pid; -%% when R11 goes away, drop the line beneath and uncomment the line above +%% when R12 goes away, drop the line beneath and uncomment the line above name(Name) -> Name. unregister_name({local,Name}) -> diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index 6f52dd7c08..8f41392f83 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -341,16 +341,7 @@ delete_transient_forward_routes(Route) -> ok = mnesia:delete_object(rabbit_route, Route, write). contains(Table, MatchHead) -> - try - continue(mnesia:select(Table, [{MatchHead, [], ['$_']}], 1, read)) - catch exit:{aborted, {badarg, _}} -> - %% work around OTP-7025, which was fixed in R12B-1, by - %% falling back on a less efficient method - case mnesia:match_object(Table, MatchHead, read) of - [] -> false; - [_|_] -> true - end - end. + continue(mnesia:select(Table, [{MatchHead, [], ['$_']}], 1, read)). continue('$end_of_table') -> false; continue({[_|_], _}) -> true; diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 59ba277610..723b818b41 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -537,51 +537,19 @@ pid_to_string(Pid) when is_pid(Pid) -> %% inverse of above string_to_pid(Str) -> - ErrorFun = fun () -> throw({error, {invalid_pid_syntax, Str}}) end, - %% TODO: simplify this code by using the 're' module, once we drop - %% support for R11 - %% - %% 1) sanity check %% The \ before the trailing $ is only there to keep emacs %% font-lock from getting confused. - case regexp:first_match(Str, "^<.*\\.[0-9]+\\.[0-9]+>\$") of - {match, _, _} -> - %% 2) strip <> - Str1 = string:substr(Str, 2, string:len(Str) - 2), - %% 3) extract three constituent parts, taking care to - %% handle dots in the node part (hence the reverse and concat) - [SerStr, IdStr | Rest] = lists:reverse(string:tokens(Str1, ".")), - NodeStr = lists:concat(lists:reverse(Rest)), - %% 4) construct a triple term from the three parts - TripleStr = lists:flatten(io_lib:format("{~s,~s,~s}.", - [NodeStr, IdStr, SerStr])), - %% 5) parse the triple - Tokens = case erl_scan:string(TripleStr) of - {ok, Tokens1, _} -> Tokens1; - {error, _, _} -> ErrorFun() - end, - Term = case erl_parse:parse_term(Tokens) of - {ok, Term1} -> Term1; - {error, _} -> ErrorFun() - end, - {Node, Id, Ser} = - case Term of - {Node1, Id1, Ser1} when is_atom(Node1) andalso - is_integer(Id1) andalso - is_integer(Ser1) -> - Term; - _ -> - ErrorFun() - end, - %% 6) turn the triple into a pid - see pid_to_string - <<131,NodeEnc/binary>> = term_to_binary(Node), + case re:run(Str, "^<(.*)\\.([0-9]+)\\.([0-9]+)>\$", + [{capture,all_but_first,list}]) of + {match, [NodeStr, IdStr, SerStr]} -> + %% turn the triple into a pid - see pid_to_string + <<131,NodeEnc/binary>> = term_to_binary(list_to_atom(NodeStr)), + Id = list_to_integer(IdStr), + Ser = list_to_integer(SerStr), binary_to_term(<<131,103,NodeEnc/binary,Id:32,Ser:32,0:8>>); nomatch -> - ErrorFun(); - Error -> - %% invalid regexp - shouldn't happen - throw(Error) - end. + throw({error, {invalid_pid_syntax, Str}}) + end. version_compare(A, B, lte) -> case version_compare(A, B) of diff --git a/src/rabbit_persister.erl b/src/rabbit_persister.erl index a8e41baf74..3cd42e4753 100644 --- a/src/rabbit_persister.erl +++ b/src/rabbit_persister.erl @@ -184,9 +184,7 @@ handle_cast(_Msg, State) -> handle_info(timeout, State = #pstate{deadline = infinity}) -> State1 = flush(true, State), - %% TODO: Once we drop support for R11B-5, we can change this to - %% {noreply, State1, hibernate}; - proc_lib:hibernate(gen_server2, enter_loop, [?MODULE, [], State1]); + {noreply, State1, hibernate}; handle_info(timeout, State) -> do_noreply(flush(State)); handle_info(_Info, State) -> diff --git a/src/rabbit_router.erl b/src/rabbit_router.erl index a449e19eb4..a6300cc8e6 100644 --- a/src/rabbit_router.erl +++ b/src/rabbit_router.erl @@ -137,20 +137,7 @@ match_bindings(Name, Match) -> mnesia:table(rabbit_route), ExchangeName == Name, Match(Binding)]), - lookup_qpids( - try - mnesia:async_dirty(fun qlc:e/1, [Query]) - catch exit:{aborted, {badarg, _}} -> - %% work around OTP-7025, which was fixed in R12B-1, by - %% falling back on a less efficient method - [QName || #route{binding = Binding = #binding{ - queue_name = QName}} <- - mnesia:dirty_match_object( - rabbit_route, - #route{binding = #binding{exchange_name = Name, - _ = '_'}}), - Match(Binding)] - end). + lookup_qpids(mnesia:async_dirty(fun qlc:e/1, [Query])). match_routing_key(Name, RoutingKey) -> MatchHead = #route{binding = #binding{exchange_name = Name, |
