summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klishin <michael@clojurewerkz.org>2020-07-09 22:02:09 +0300
committerMichael Klishin <michael@clojurewerkz.org>2020-07-14 03:50:33 +0300
commitf7a9449c6741de71e83af697220ec2f1bc5cabbd (patch)
treeb156737c53ca30a107d04d82f39fcde35b7e973f
parent42817a936533f243a16d8eddfcde8162789d5e6a (diff)
downloadrabbitmq-server-git-f7a9449c6741de71e83af697220ec2f1bc5cabbd.tar.gz
Extract rabbit_networking:stop_ranch_listener_of_protocol/1
Part of rabbitmq/rabbitmq-server#2321
-rw-r--r--src/rabbit_networking.erl12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/rabbit_networking.erl b/src/rabbit_networking.erl
index 0aa5f2e777..ff82a23ab3 100644
--- a/src/rabbit_networking.erl
+++ b/src/rabbit_networking.erl
@@ -30,7 +30,7 @@
close_connection/2, close_connections/2,
force_connection_event_refresh/1, handshake/2, tcp_host/1,
ranch_ref/1, ranch_ref/2, ranch_ref_of_protocol/1,
- listener_of_protocol/1]).
+ listener_of_protocol/1, stop_ranch_listener_of_protocol/1]).
%% Used by TCP-based transports, e.g. STOMP adapter
-export([tcp_listener_addresses/1, tcp_listener_spec/9,
@@ -234,6 +234,16 @@ listener_of_protocol(Protocol) ->
end
end).
+-spec stop_ranch_listener_of_protocol(atom()) -> ok | {error, not_found}.
+stop_ranch_listener_of_protocol(Protocol) ->
+ case rabbit_networking:ranch_ref_of_protocol(Protocol) of
+ {error, not_found} -> ok;
+ undefined -> ok;
+ Ref ->
+ rabbit_log:debug("Stopping Ranch listener for protocol ~s", [Protocol]),
+ ranch:stop_listener(Ref)
+ end.
+
-spec start_tcp_listener(
listener_config(), integer()) -> 'ok' | {'error', term()}.