Skip to content

Commit 5cd7665

Browse files
committed
Remove the use of infinity in rabbit_web_dispatch_registry
This PR changes three `gen_server:call` invocations to use a 60 second timeout, rather than infinity. It's part of a larger undertaking to evaluate and, possibly, remove other usages of `infinity` in the RabbitMQ codebase. The motivation for this particular change is evidence of `rabbit_web_dispatch_registry:remove/1` never returning during a broker shutdown, after that broker had been put into maintenance mode. This is most likely a one-off event, but the `infinity` timeout didn't help.
1 parent 0bc3411 commit 5cd7665

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

deps/rabbit_common/include/rabbit.hrl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,5 @@
277277
%% Max value for stream max segment size
278278
-define(MAX_STREAM_MAX_SEGMENT_SIZE, 3_000_000_000).
279279

280+
%% Preferred value instead of `infinity`
281+
-define(GEN_SERVER_CALL_TIMEOUT, 60000).

deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_registry.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
-module(rabbit_web_dispatch_registry).
99

1010
-include_lib("kernel/include/logger.hrl").
11-
11+
-include_lib("rabbit_common/include/rabbit.hrl").
1212

1313
-behaviour(gen_server).
1414

@@ -30,10 +30,10 @@ start_link() ->
3030

3131
add(Name, Listener, Selector, Handler, Link) ->
3232
gen_server:call(?MODULE, {add, Name, Listener, Selector, Handler, Link},
33-
infinity).
33+
?GEN_SERVER_CALL_TIMEOUT).
3434

3535
remove(Name) ->
36-
gen_server:call(?MODULE, {remove, Name}, infinity).
36+
gen_server:call(?MODULE, {remove, Name}, ?GEN_SERVER_CALL_TIMEOUT).
3737

3838
%% @todo This needs to be dispatch instead of a fun too.
3939
%% But I'm not sure what code is using this.
@@ -56,7 +56,7 @@ lookup(Listener, Req) ->
5656
%% This is called in a somewhat obfuscated manner in
5757
%% rabbit_mgmt_external_stats:rabbit_web_dispatch_registry_list_all()
5858
list_all() ->
59-
gen_server:call(?MODULE, list_all, infinity).
59+
gen_server:call(?MODULE, list_all, ?GEN_SERVER_CALL_TIMEOUT).
6060

6161
%% Callback Methods
6262

0 commit comments

Comments
 (0)