diff options
-rw-r--r-- | src/rabbit_amqqueue_process.erl | 5 | ||||
-rw-r--r-- | src/rabbit_limiter.erl | 9 | ||||
-rw-r--r-- | src/rabbit_tests.erl | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 991f5416..9e8628e4 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -58,7 +58,7 @@ %% These are held in our process dictionary -record(cr, {consumer_count, ch_pid, - limiter = rabbit_limiter:make_token(undefined), + limiter, monitor_ref, acktags, is_limit_active, @@ -322,6 +322,7 @@ ch_record(ChPid) -> monitor_ref = MonitorRef, acktags = sets:new(), is_limit_active = false, + limiter = rabbit_limiter:make_token(), unsent_message_count = 0}, put(Key, C), C; @@ -953,7 +954,7 @@ handle_call({basic_cancel, ChPid, ConsumerTag, OkMsg}, _From, maybe_store_ch_record( case ConsumerCount of 1 -> ok = rabbit_limiter:unregister(Limiter, self()), - C1#cr{limiter = rabbit_limiter:make_token(undefined)}; + C1#cr{limiter = rabbit_limiter:make_token()}; _ -> C1 end), emit_consumer_deleted(ChPid, ConsumerTag), diff --git a/src/rabbit_limiter.erl b/src/rabbit_limiter.erl index 1104d33c..2d367707 100644 --- a/src/rabbit_limiter.erl +++ b/src/rabbit_limiter.erl @@ -20,13 +20,14 @@ -export([init/1, terminate/2, code_change/3, handle_call/3, handle_cast/2, handle_info/2, prioritise_call/3]). --export([start_link/0, make_token/1, is_enabled/1, enable/2, disable/1]). +-export([start_link/0, make_token/0, make_token/1, is_enabled/1, enable/2, + disable/1]). -export([limit/2, can_send/3, ack/2, register/2, unregister/2]). -export([get_limit/1, block/1, unblock/1, is_blocked/1]). %%---------------------------------------------------------------------------- --record(token, {pid, enabled = false}). +-record(token, {pid, enabled}). -ifdef(use_specs). @@ -35,6 +36,7 @@ -opaque(token() :: #token{}). -spec(start_link/0 :: () -> rabbit_types:ok_pid_or_error()). +-spec(make_token/0 :: () -> token()). -spec(make_token/1 :: (undefined | pid()) -> token()). -spec(is_enabled/1 :: (token()) -> boolean()). -spec(enable/2 :: (token(), non_neg_integer()) -> token()). @@ -68,7 +70,8 @@ start_link() -> gen_server2:start_link(?MODULE, [], []). -make_token(Pid) -> #token{pid = Pid}. +make_token() -> make_token(undefined). +make_token(Pid) -> #token{pid = Pid, enabled = false}. is_enabled(#token{enabled = Enabled}) -> Enabled. diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index 0ee59e1e..8b463f4c 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -1207,7 +1207,7 @@ test_server_status() -> false, false, [], none)]], ok = rabbit_amqqueue:basic_consume( - Q, true, Ch, rabbit_limiter:make_token(undefined), + Q, true, Ch, rabbit_limiter:make_token(), <<"ctag">>, true, undefined), %% list queues |