summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_binary_generator.erl19
-rw-r--r--src/rabbit_mixed_queue.erl11
2 files changed, 22 insertions, 8 deletions
diff --git a/src/rabbit_binary_generator.erl b/src/rabbit_binary_generator.erl
index 6cfa9e6d17..0b68f33f41 100644
--- a/src/rabbit_binary_generator.erl
+++ b/src/rabbit_binary_generator.erl
@@ -46,6 +46,7 @@
build_heartbeat_frame/0]).
-export([generate_table/1, encode_properties/2]).
-export([check_empty_content_body_frame_size/0]).
+-export([ensure_content_encoded/1, clear_encoded_content/1]).
-import(lists).
@@ -63,6 +64,8 @@
-spec(generate_table/1 :: (amqp_table()) -> binary()).
-spec(encode_properties/2 :: ([amqp_property_type()], [any()]) -> binary()).
-spec(check_empty_content_body_frame_size/0 :: () -> 'ok').
+-spec(ensure_content_encoded/1 :: (content()) -> encoded_content()).
+-spec(clear_encoded_content/1 :: (content()) -> unencoded_content()).
-endif.
@@ -275,3 +278,19 @@ check_empty_content_body_frame_size() ->
exit({incorrect_empty_content_body_frame_size,
ComputedSize, ?EMPTY_CONTENT_BODY_FRAME_SIZE})
end.
+
+ensure_content_encoded(Content = #content{properties_bin = PropsBin})
+ when PropsBin =/= 'none' ->
+ Content;
+ensure_content_encoded(Content = #content{properties = Props}) ->
+ Content #content{properties_bin = rabbit_framing:encode_properties(Props)}.
+
+clear_encoded_content(Content = #content{properties_bin = none}) ->
+ Content;
+clear_encoded_content(Content = #content{properties = none}) ->
+ %% Only clear when we can rebuild the properties later in
+ %% accordance to the content record definition comment - maximum
+ %% one of properties and properties_bin can be 'none'
+ Content;
+clear_encoded_content(Content = #content{}) ->
+ Content#content{properties_bin = none}.
diff --git a/src/rabbit_mixed_queue.erl b/src/rabbit_mixed_queue.erl
index 9e0eb13f5e..a80cadf35d 100644
--- a/src/rabbit_mixed_queue.erl
+++ b/src/rabbit_mixed_queue.erl
@@ -121,14 +121,9 @@ size_of_message(
SumAcc + size(Frag)
end, 0, Payload).
-ensure_binary_properties(Msg = #basic_message {
- content = Content = #content {
- properties = Props,
- properties_bin = none }}) ->
- Msg #basic_message { content = Content #content {
- properties_bin = rabbit_framing:encode_properties(Props) }};
-ensure_binary_properties(Msg) ->
- Msg.
+ensure_binary_properties(Msg = #basic_message { content = Content }) ->
+ Msg #basic_message { content = rabbit_binary_generator:
+ ensure_content_encoded(Content) }.
set_storage_mode(Mode, _TxnMessages, State = #mqstate { mode = Mode }) ->
{ok, State};