summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-03-15 16:31:48 +0000
committerSimon MacMullen <simon@rabbitmq.com>2012-03-15 16:31:48 +0000
commitcfe297ce81d7fee179316880d7605b9271715a80 (patch)
tree5530ffd0d133cb984da374991e0ba13a3c509dd6
parentd7181b984247257cf0f52fa86b42129aa8674782 (diff)
downloadrabbitmq-server-cfe297ce81d7fee179316880d7605b9271715a80.tar.gz
Simple test for multi call - and reverse the lists so they come out the same order they went in.bug24794
-rw-r--r--src/rabbit_misc.erl2
-rw-r--r--src/rabbit_tests.erl21
2 files changed, 22 insertions, 1 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 3f3aeb62..ddf7f574 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -896,7 +896,7 @@ start_multi_call(Pid, Req) when is_pid(Pid) ->
{Mref, Pid}.
receive_multi_call([], Good, Bad) ->
- {Good, Bad};
+ {lists:reverse(Good), lists:reverse(Bad)};
receive_multi_call([{Mref, Pid} | MonitorPids], Good, Bad) ->
receive
{Mref, Reply} ->
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index f7e3baa7..85fe5426 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -35,6 +35,7 @@ all_tests() ->
passed = mirrored_supervisor_tests:all_tests(),
application:set_env(rabbit, file_handles_high_watermark, 10, infinity),
ok = file_handle_cache:set_limit(10),
+ passed = test_multi_call(),
passed = test_file_handle_cache(),
passed = test_backing_queue(),
passed = test_priority_queue(),
@@ -107,6 +108,26 @@ run_cluster_dependent_tests(SecondaryNode) ->
passed.
+test_multi_call() ->
+ Fun = fun() ->
+ receive
+ {'$gen_call', {From, Mref}, request} ->
+ From ! {Mref, response}
+ end,
+ receive
+ never -> ok
+ end
+ end,
+ Pid1 = spawn(Fun),
+ Pid2 = spawn(Fun),
+ Pid3 = spawn(Fun),
+ exit(Pid2, bang),
+ {[{Pid1, response}, {Pid3, response}], [{Pid2, _Fail}]} =
+ rabbit_misc:multi_call([Pid1, Pid2, Pid3], request),
+ exit(Pid1, bang),
+ exit(Pid3, bang),
+ passed.
+
test_priority_queue() ->
false = priority_queue:is_queue(not_a_queue),