summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2011-02-11 13:18:54 +0000
committerMatthew Sackman <matthew@rabbitmq.com>2011-02-11 13:18:54 +0000
commit7764d9347e2f9305d9135531f03861f7e740d2cd (patch)
tree3ec576cf135ad001047d772b626182a911875c19
parentbb2925295671a7c1a5b9526804a848eeacd63183 (diff)
downloadrabbitmq-server-7764d9347e2f9305d9135531f03861f7e740d2cd.tar.gz
Move the state modification into rollback_and_notify
-rw-r--r--src/rabbit_channel.erl29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index cdf8015c..74a93f9f 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -306,15 +306,12 @@ handle_pre_hibernate(State = #ch{stats_timer = StatsTimer}) ->
{hibernate, State#ch{stats_timer = StatsTimer1}}.
terminate(Reason, State) ->
- case State#ch.state of
- closing -> ok;
- _ -> Res = rollback_and_notify(State),
- case Reason of
- normal -> ok = Res;
- shutdown -> ok = Res;
- {shutdown, _Term} -> ok = Res;
- _ -> ok
- end
+ {Res, _State1} = rollback_and_notify(State),
+ case Reason of
+ normal -> ok = Res;
+ shutdown -> ok = Res;
+ {shutdown, _Term} -> ok = Res;
+ _ -> ok
end,
pg_local:leave(rabbit_channels, self()),
rabbit_event:notify(channel_closed, [{pid, self()}]).
@@ -364,8 +361,7 @@ send_exception(Reason, State = #ch{protocol = Protocol,
rabbit_log:error("connection ~p, channel ~p - error:~n~p~n",
[ReaderPid, Channel, Reason]),
%% something bad's happened: rollback_and_notify make not be 'ok'
- rollback_and_notify(State),
- State1 = State#ch{state = closing},
+ {_Result, State1} = rollback_and_notify(State),
case CloseChannel of
Channel ->
ok = rabbit_writer:send_command(WriterPid, CloseMethod),
@@ -561,8 +557,8 @@ handle_method(#'channel.close'{}, _, State = #ch{reader_pid = ReaderPid,
fun () -> ok = gen_server2:cast(Self, closed) end},
%% no error, so rollback_and_notify should be 'ok'. Do in parallel
%% with the reader picking up our message and running our Fun.
- ok = rollback_and_notify(State),
- {noreply, State#ch{state = closing}};
+ {ok, State1} = rollback_and_notify(State),
+ {noreply, State1};
handle_method(#'access.request'{},_, State) ->
{reply, #'access.request_ok'{ticket = 1}, State};
@@ -1202,10 +1198,13 @@ internal_rollback(State = #ch{transaction_id = TxnKey,
NewUAMQ = queue:join(UAQ, UAMQ),
new_tx(State#ch{unacked_message_q = NewUAMQ}).
+rollback_and_notify(State = #ch{state = closing}) ->
+ {ok, State};
rollback_and_notify(State = #ch{transaction_id = none}) ->
- notify_queues(State);
+ {notify_queues(State), State#ch{state = closing}};
rollback_and_notify(State) ->
- notify_queues(internal_rollback(State)).
+ State1 = internal_rollback(State),
+ {notify_queues(State1), State1#ch{state = closing}}.
fold_per_queue(F, Acc0, UAQ) ->
D = rabbit_misc:queue_fold(