summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2011-02-11 13:27:28 +0000
committerMatthew Sackman <matthew@rabbitmq.com>2011-02-11 13:27:28 +0000
commiteec000ad98d1a4cf1cd0638ab97b20c7c8fead73 (patch)
tree490a86bc63cbebea50f993b13c98a8de7b335978 /src
parent2bfc5a5d00549c76e484ad4613fb7f8f3096adb6 (diff)
downloadrabbitmq-server-git-eec000ad98d1a4cf1cd0638ab97b20c7c8fead73.tar.gz
drop CPS in favour of explicit API
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_channel.erl13
-rw-r--r--src/rabbit_reader.erl4
2 files changed, 10 insertions, 7 deletions
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 74a93f9f47..180e9393c2 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -23,7 +23,7 @@
-export([start_link/8, do/2, do/3, flush/1, shutdown/1]).
-export([send_command/2, deliver/4, flushed/2, confirm/2]).
-export([list/0, info_keys/0, info/1, info/2, info_all/0, info_all/1]).
--export([emit_stats/1]).
+-export([emit_stats/1, ready_for_close/1]).
-export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2,
handle_info/2, handle_pre_hibernate/1, prioritise_call/3,
@@ -89,6 +89,7 @@
-spec(info_all/0 :: () -> [rabbit_types:infos()]).
-spec(info_all/1 :: (rabbit_types:info_keys()) -> [rabbit_types:infos()]).
-spec(emit_stats/1 :: (pid()) -> 'ok').
+-spec(ready_for_close/1 :: (pid()) -> 'ok').
-endif.
@@ -147,6 +148,9 @@ info_all(Items) ->
emit_stats(Pid) ->
gen_server2:cast(Pid, emit_stats).
+ready_for_close(Pid) ->
+ gen_server2:cast(Pid, ready_for_close).
+
%%---------------------------------------------------------------------------
init([Protocol, Channel, ReaderPid, WriterPid, User, VHost, CollectorPid,
@@ -232,7 +236,8 @@ handle_cast({method, Method, Content}, State) ->
handle_cast({flushed, QPid}, State) ->
{noreply, queue_blocked(QPid, State), hibernate};
-handle_cast(closed, State = #ch{state = closing, writer_pid = WriterPid}) ->
+handle_cast(ready_for_close, State = #ch{state = closing,
+ writer_pid = WriterPid}) ->
ok = rabbit_writer:send_command_sync(WriterPid, #'channel.close_ok'{}),
{stop, normal, State};
@@ -552,9 +557,7 @@ handle_method(_Method, _, State = #ch{state = closing}) ->
handle_method(#'channel.close'{}, _, State = #ch{reader_pid = ReaderPid,
channel = Channel}) ->
- Self = self(),
- ReaderPid ! {channel_closing, Channel,
- fun () -> ok = gen_server2:cast(Self, closed) end},
+ ReaderPid ! {channel_closing, Channel, self()},
%% no error, so rollback_and_notify should be 'ok'. Do in parallel
%% with the reader picking up our message and running our Fun.
{ok, State1} = rollback_and_notify(State),
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index a45166afa5..f950bb00ed 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -242,8 +242,8 @@ mainloop(Deb, State = #v1{parent = Parent, sock= Sock, recv_ref = Ref}) ->
throw({inet_error, Reason});
{conserve_memory, Conserve} ->
mainloop(Deb, internal_conserve_memory(Conserve, State));
- {channel_closing, Channel, Fun} ->
- ok = Fun(),
+ {channel_closing, Channel, ChPid} ->
+ ok = rabbit_channel:ready_for_close(ChPid),
erase({channel, Channel}),
mainloop(Deb, State);
{'EXIT', Parent, Reason} ->