summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkjnilsson <knilsson@pivotal.io>2019-03-20 09:58:40 +0000
committerkjnilsson <knilsson@pivotal.io>2019-03-20 09:58:40 +0000
commit1ff2630eef3e7ddbc3841a888a05b24cd3c2aff9 (patch)
treef11c68450cbe5ca257331ff2e46fe5e88df76888 /src
parent7d4fcc644718f749f86b5207dac435d2cccb5664 (diff)
downloadrabbitmq-server-git-1ff2630eef3e7ddbc3841a888a05b24cd3c2aff9.tar.gz
rabbit_fifo: propery tests for single active consumer
To test send_msg ordering and ensure there never two active consumers at once. [#164691411]
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_fifo.erl11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/rabbit_fifo.erl b/src/rabbit_fifo.erl
index b966dca82e..9da3a6913c 100644
--- a/src/rabbit_fifo.erl
+++ b/src/rabbit_fifo.erl
@@ -327,9 +327,16 @@ apply(Meta, {down, Pid, noconnection},
Credit = increase_credit(C0, maps:size(Checked)),
{St, Effs1} = return_all(State0, Effs,
Cid, C0#consumer{credit = Credit}),
- #{Cid := C} = St#?MODULE.consumers,
+ %% if the consumer was cancelled there is a chance it got
+ %% removed when returning hence we need to be defensive here
+ Waiting = case St#?MODULE.consumers of
+ #{Cid := C} ->
+ Waiting0 ++ [{Cid, C}];
+ _ ->
+ Waiting0
+ end,
{St#?MODULE{consumers = #{},
- waiting_consumers = Waiting0 ++ [{Cid, C}]},
+ waiting_consumers = Waiting},
Effs1};
_ -> {State0, []}
end,