Skip to content

Commit

Permalink
Remove explicit cleanup from stopping listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
juhlig committed Jul 4, 2024
1 parent a2c959e commit d9a9521
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/ranch.erl
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,15 @@ start_error(_, Error) -> Error.
stop_listener(Ref) ->
%% We need to provide an integer timeout to erpc:call,
%% otherwise the function will be executed in the calling
%% process. 16#ffffffff is as close to 'infinity' as we
%% can get.
erpc:call(node(), fun() -> stop_listener1(Ref) end, 16#ffffffff).
%% process. 5 minutes should be enough.
erpc:call(node(), fun() -> stop_listener1(Ref) end, 300000).

stop_listener1(Ref) ->
TransportAndOpts = maybe_get_transport_and_opts(Ref),
case supervisor:terminate_child(ranch_sup, {ranch_listener_sup, Ref}) of
ok ->
_ = supervisor:delete_child(ranch_sup, {ranch_listener_sup, Ref}),
ranch_server:cleanup_listener_opts(Ref),
stop_listener2(TransportAndOpts);
{error, _} = Error ->
Error
end.
_ = supervisor:terminate_child(ranch_sup, {ranch_listener_sup, Ref}),
Result = supervisor:delete_child(ranch_sup, {ranch_listener_sup, Ref}),
ok = stop_listener2(TransportAndOpts),
Result.

stop_listener2({Transport, TransOpts}) ->
Transport:cleanup(TransOpts),
Expand Down

0 comments on commit d9a9521

Please sign in to comment.