diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2012-04-10 15:36:30 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-04-10 15:36:30 +0100 |
commit | 8225d8f7d81e2f130f5664bc73eb94162a5f4377 (patch) | |
tree | 8f1e2348acb342c6d64cdf97c436c527666a804c | |
parent | a3c3c87c0621c8969e68d1b8b78da7c656f21a8f (diff) | |
parent | d5dbd981228386df94e74b5736ab97ec91ee7629 (diff) | |
download | rabbitmq-server-8225d8f7d81e2f130f5664bc73eb94162a5f4377.tar.gz |
merge bug24846 into default
-rw-r--r-- | packaging/debs/Debian/debian/postrm.in | 9 | ||||
-rw-r--r-- | src/rabbit_amqqueue_process.erl | 38 | ||||
-rw-r--r-- | src/rabbit_basic.erl | 13 |
3 files changed, 31 insertions, 29 deletions
diff --git a/packaging/debs/Debian/debian/postrm.in b/packaging/debs/Debian/debian/postrm.in index baf081fc..c2e9bbfe 100644 --- a/packaging/debs/Debian/debian/postrm.in +++ b/packaging/debs/Debian/debian/postrm.in @@ -35,20 +35,15 @@ case "$1" in if [ -d /etc/rabbitmq ]; then rm -r /etc/rabbitmq fi - remove_plugin_traces + remove_plugin_traces if getent passwd rabbitmq >/dev/null; then # Stop epmd if run by the rabbitmq user pkill -u rabbitmq epmd || : - - deluser rabbitmq - fi - if getent group rabbitmq >/dev/null; then - delgroup rabbitmq fi ;; remove|upgrade) - remove_plugin_traces + remove_plugin_traces ;; failed-upgrade|abort-install|abort-upgrade|disappear) diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 21e576a6..eb9ee835 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -830,29 +830,33 @@ make_dead_letter_msg(DLX, Reason, exchange_name = Exchange, routing_keys = RoutingKeys}, State = #q{dlx_routing_key = DlxRoutingKey}) -> - Headers = rabbit_basic:extract_headers(Content), - #resource{name = QName} = qname(State), - %% The first routing key is the one specified in the - %% basic.publish; all others are CC or BCC keys. - RoutingKeys1 = [hd(RoutingKeys) | rabbit_basic:header_routes(Headers)], - Info = [{<<"reason">>, longstr, list_to_binary(atom_to_list(Reason))}, - {<<"queue">>, longstr, QName}, - {<<"time">>, timestamp, rabbit_misc:now_ms() div 1000}, - {<<"exchange">>, longstr, Exchange#resource.name}, - {<<"routing-keys">>, array, - [{longstr, Key} || Key <- RoutingKeys1]}], - Headers1 = rabbit_basic:append_table_header(<<"x-death">>, Info, Headers), - {DeathRoutingKeys, Headers2} = + {DeathRoutingKeys, HeadersFun1} = case DlxRoutingKey of - undefined -> {RoutingKeys, Headers1}; + undefined -> {RoutingKeys, fun (H) -> H end}; _ -> {[DlxRoutingKey], - lists:keydelete(<<"CC">>, 1, Headers1)} + fun (H) -> lists:keydelete(<<"CC">>, 1, H) end} + end, + #resource{name = QName} = qname(State), + HeadersFun2 = + fun (Headers) -> + %% The first routing key is the one specified in the + %% basic.publish; all others are CC or BCC keys. + RoutingKeys1 = + [hd(RoutingKeys) | rabbit_basic:header_routes(Headers)], + Info = [{<<"reason">>, + longstr, list_to_binary(atom_to_list(Reason))}, + {<<"queue">>, longstr, QName}, + {<<"time">>, timestamp, rabbit_misc:now_ms() div 1000}, + {<<"exchange">>, longstr, Exchange#resource.name}, + {<<"routing-keys">>, array, + [{longstr, Key} || Key <- RoutingKeys1]}], + HeadersFun1(rabbit_basic:append_table_header(<<"x-death">>, + Info, Headers)) end, - Content1 = rabbit_basic:replace_headers(Headers2, Content), + Content1 = rabbit_basic:map_headers(HeadersFun2, Content), Msg#basic_message{exchange_name = DLX, id = rabbit_guid:gen(), routing_keys = DeathRoutingKeys, content = Content1}. - now_micros() -> timer:now_diff(now(), {0,0,0}). infos(Items, State) -> diff --git a/src/rabbit_basic.erl b/src/rabbit_basic.erl index a89aa074..8ad59016 100644 --- a/src/rabbit_basic.erl +++ b/src/rabbit_basic.erl @@ -20,7 +20,7 @@ -export([publish/4, publish/6, publish/1, message/3, message/4, properties/1, append_table_header/3, - extract_headers/1, replace_headers/2, delivery/4, header_routes/1]). + extract_headers/1, map_headers/2, delivery/4, header_routes/1]). -export([build_content/2, from_content/1]). %%---------------------------------------------------------------------------- @@ -63,8 +63,8 @@ -spec(extract_headers/1 :: (rabbit_types:content()) -> headers()). --spec(replace_headers/2 :: (headers(), rabbit_types:content()) - -> rabbit_types:content()). +-spec(map_headers/2 :: (rabbit_types:content(), fun((headers()) -> headers())) + -> rabbit_types:content()). -spec(header_routes/1 :: (undefined | rabbit_framing:amqp_table()) -> [string()]). @@ -193,9 +193,12 @@ extract_headers(Content) -> rabbit_binary_parser:ensure_content_decoded(Content), Headers. -replace_headers(Headers, Content = #content{properties = Props}) -> +map_headers(F, Content) -> + Content1 = rabbit_binary_parser:ensure_content_decoded(Content), + #content{properties = #'P_basic'{headers = Headers} = Props} = Content1, + Headers1 = F(Headers), rabbit_binary_generator:clear_encoded_content( - Content#content{properties = Props#'P_basic'{headers = Headers}}). + Content1#content{properties = Props#'P_basic'{headers = Headers1}}). indexof(L, Element) -> indexof(L, Element, 1). |