Skip to content

Commit a02a114

Browse files
committed
merge bug21583 into default
2 parents d15cc2d + 8a3e49b commit a02a114

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/rabbit_channel.erl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ handle_cast({method, Method, Content}, State) ->
126126
{stop, normal, State#ch{state = terminating}}
127127
catch
128128
exit:{amqp, Error, Explanation, none} ->
129-
ok = notify_queues(internal_rollback(State)),
129+
ok = rollback_and_notify(State),
130130
Reason = {amqp, Error, Explanation,
131131
rabbit_misc:method_record_type(Method)},
132132
State#ch.reader_pid ! {channel_exit, State#ch.channel, Reason},
@@ -175,7 +175,7 @@ terminate(_Reason, #ch{writer_pid = WriterPid, limiter_pid = LimiterPid,
175175

176176
terminate(Reason, State = #ch{writer_pid = WriterPid,
177177
limiter_pid = LimiterPid}) ->
178-
Res = notify_queues(internal_rollback(State)),
178+
Res = rollback_and_notify(State),
179179
case Reason of
180180
normal -> ok = Res;
181181
_ -> ok
@@ -297,7 +297,7 @@ handle_method(_Method, _, #ch{state = starting}) ->
297297
rabbit_misc:protocol_error(channel_error, "expected 'channel.open'", []);
298298

299299
handle_method(#'channel.close'{}, _, State = #ch{writer_pid = WriterPid}) ->
300-
ok = notify_queues(internal_rollback(State)),
300+
ok = rollback_and_notify(State),
301301
ok = rabbit_writer:send_command(WriterPid, #'channel.close_ok'{}),
302302
stop;
303303

@@ -872,6 +872,11 @@ internal_rollback(State = #ch{transaction_id = TxnKey,
872872
internal_error, "rollback failed: ~w", [Errors])
873873
end.
874874

875+
rollback_and_notify(State = #ch{transaction_id = none}) ->
876+
notify_queues(State);
877+
rollback_and_notify(State) ->
878+
notify_queues(internal_rollback(State)).
879+
875880
fold_per_queue(F, Acc0, UAQ) ->
876881
D = lists:foldl(
877882
fun ({_DTag, _CTag,

0 commit comments

Comments
 (0)