diff options
| author | Matthew Sackman <matthew@rabbitmq.com> | 2010-07-21 16:46:41 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@rabbitmq.com> | 2010-07-21 16:46:41 +0100 |
| commit | 8b18c30283e796730cb5377c556a8dde4844de18 (patch) | |
| tree | f5c2f1478042e3cd29fdc66cddf5f58912ab84f8 | |
| parent | 990da82944cd356c7ce9c909f250385dc07949f2 (diff) | |
| download | rabbitmq-server-git-8b18c30283e796730cb5377c556a8dde4844de18.tar.gz | |
Fixed channel shutdown mechanisms
| -rw-r--r-- | src/rabbit_channel.erl | 7 | ||||
| -rw-r--r-- | src/rabbit_channel_sup.erl | 10 | ||||
| -rw-r--r-- | src/rabbit_channel_sup_sup.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_connection_sup.erl | 6 | ||||
| -rw-r--r-- | src/rabbit_reader.erl | 1 | ||||
| -rw-r--r-- | src/rabbit_writer.erl | 16 |
6 files changed, 21 insertions, 21 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index 9cfc9e27ee..5757d9f369 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -232,8 +232,7 @@ handle_cast({method, Method, Content}, State) -> handle_cast({flushed, QPid}, State) -> {noreply, queue_blocked(QPid, State)}; -handle_cast(terminate, State = #ch{parent_pid = ParentPid}) -> - rabbit_channel_sup:stop(ParentPid), +handle_cast(terminate, State) -> {stop, shutdown, State}; handle_cast({command, Msg}, State = #ch{writer_pid = WriterPid}) -> @@ -1130,8 +1129,8 @@ internal_deliver(WriterPid, Notify, ConsumerTag, DeliveryTag, terminate(#ch{writer_pid = WriterPid, limiter_pid = LimiterPid}) -> pg_local:leave(rabbit_channels, self()), - rabbit_writer:shutdown(WriterPid), - rabbit_limiter:shutdown(LimiterPid). + rabbit_limiter:shutdown(LimiterPid), + rabbit_writer:flush(WriterPid). infos(Items, State) -> [{Item, i(Item, State)} || Item <- Items]. diff --git a/src/rabbit_channel_sup.erl b/src/rabbit_channel_sup.erl index 0e716b4808..7a7c7b7944 100644 --- a/src/rabbit_channel_sup.erl +++ b/src/rabbit_channel_sup.erl @@ -73,11 +73,11 @@ framing_channel(Pid) -> init([Sock, Channel, FrameMax, ReaderPid, Username, VHost, Collector]) -> {ok, {{one_for_all, 0, 1}, - [{channel, {rabbit_channel, start_link, - [Channel, ReaderPid, Username, VHost, Collector]}, - permanent, ?MAX_WAIT, worker, [rabbit_channel]}, + [{framing_channel, {rabbit_framing_channel, start_link, []}, + permanent, ?MAX_WAIT, worker, [rabbit_framing_channel]}, {writer, {rabbit_writer, start_link, [Sock, Channel, FrameMax]}, permanent, ?MAX_WAIT, worker, [rabbit_writer]}, - {framing_channel, {rabbit_framing_channel, start_link, []}, - permanent, ?MAX_WAIT, worker, [rabbit_framing_channel]} + {channel, {rabbit_channel, start_link, + [Channel, ReaderPid, Username, VHost, Collector]}, + permanent, ?MAX_WAIT, worker, [rabbit_channel]} ]}}. diff --git a/src/rabbit_channel_sup_sup.erl b/src/rabbit_channel_sup_sup.erl index 42064709ca..2fab867841 100644 --- a/src/rabbit_channel_sup_sup.erl +++ b/src/rabbit_channel_sup_sup.erl @@ -43,7 +43,7 @@ start_link() -> init([]) -> {ok, {{simple_one_for_one_terminate, 0, 1}, [{channel_sup, {rabbit_channel_sup, start_link, []}, - transient, infinity, supervisor, [rabbit_channel_sup]}]}}. + temporary, infinity, supervisor, [rabbit_channel_sup]}]}}. start_channel(Pid, Args) -> supervisor2:start_child(Pid, Args). diff --git a/src/rabbit_connection_sup.erl b/src/rabbit_connection_sup.erl index f6bd982682..53d086f009 100644 --- a/src/rabbit_connection_sup.erl +++ b/src/rabbit_connection_sup.erl @@ -48,11 +48,11 @@ stop(Pid) -> init([]) -> {ok, {{one_for_all, 0, 1}, [{reader, {rabbit_reader, start_link, []}, - transient, ?MAX_WAIT, worker, [rabbit_reader]}, + permanent, ?MAX_WAIT, worker, [rabbit_reader]}, {collector, {rabbit_queue_collector, start_link, []}, - transient, ?MAX_WAIT, worker, [rabbit_queue_collector]}, + permanent, ?MAX_WAIT, worker, [rabbit_queue_collector]}, {channel_sup_sup, {rabbit_channel_sup_sup, start_link, []}, - transient, infinity, supervisor, [rabbit_channel_sup_sup]} + permanent, infinity, supervisor, [rabbit_channel_sup_sup]} ]}}. reader(Pid) -> diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl index 542ef32c41..99d76b8ac4 100644 --- a/src/rabbit_reader.erl +++ b/src/rabbit_reader.erl @@ -283,7 +283,6 @@ start_connection(Parent, Deb, Sock, SockTransform) -> %% %% gen_tcp:close(ClientSock), teardown_profiling(ProfilingValue), - rabbit_connection_sup:stop(Parent), exit(shutdown) end. diff --git a/src/rabbit_writer.erl b/src/rabbit_writer.erl index 581ea428bd..16436bc00a 100644 --- a/src/rabbit_writer.erl +++ b/src/rabbit_writer.erl @@ -33,7 +33,7 @@ -include("rabbit.hrl"). -include("rabbit_framing.hrl"). --export([start/3, start_link/3, shutdown/1, mainloop/1]). +-export([start/3, start_link/3, flush/1, mainloop/1]). -export([send_command/2, send_command/3, send_command_and_signal_back/3, send_command_and_signal_back/4, send_command_and_notify/5]). -export([internal_send_command/3, internal_send_command/5]). @@ -77,6 +77,7 @@ rabbit_framing:amqp_method_record(), rabbit_types:content(), non_neg_integer()) -> 'ok'). +-spec(flush/1 :: (pid()) -> 'ok'). -endif. @@ -137,8 +138,9 @@ handle_message({inet_reply, _, ok}, State) -> State; handle_message({inet_reply, _, Status}, _State) -> exit({writer, send_failed, Status}); -handle_message(shutdown, _State) -> - exit(shutdown); +handle_message({flush, Pid, Ref}, State) -> + Pid ! Ref, + State; handle_message(Message, _State) -> exit({writer, message_not_understood, Message}). @@ -164,10 +166,10 @@ send_command_and_notify(W, Q, ChPid, MethodRecord, Content) -> W ! {send_command_and_notify, Q, ChPid, MethodRecord, Content}, ok. -shutdown(W) -> - W ! shutdown, - rabbit_misc:unlink_and_capture_exit(W), - ok. +flush(W) -> + Ref = make_ref(), + W ! {flush, self(), Ref}, + receive Ref -> ok end. %--------------------------------------------------------------------------- |
