aboutsummaryrefslogtreecommitdiffstats
path: root/src/ranch.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ranch.erl')
-rw-r--r--src/ranch.erl27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/ranch.erl b/src/ranch.erl
index c9cc035..dd16f41 100644
--- a/src/ranch.erl
+++ b/src/ranch.erl
@@ -193,15 +193,24 @@ start_error(_, Error) -> Error.
-spec stop_listener(ref()) -> ok | {error, not_found}.
stop_listener(Ref) ->
- [_, Transport, _, _, _] = ranch_server:get_listener_start_args(Ref),
- TransOpts = get_transport_options(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),
- Transport:cleanup(TransOpts);
- {error, Reason} ->
- {error, Reason}
+ try
+ [_, Transport, _, _, _] = ranch_server:get_listener_start_args(Ref),
+ TransOpts = get_transport_options(Ref),
+ {Transport, TransOpts}
+ of
+ {Transport, TransOpts} ->
+ 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),
+ Transport:cleanup(TransOpts),
+ ok;
+ {error, Reason} ->
+ {error, Reason}
+ end
+ catch
+ error:badarg ->
+ {error, not_found}
end.
-spec suspend_listener(ref()) -> ok | {error, any()}.