From 88d32b1064892d91a2657924eff4234c8a968a16 Mon Sep 17 00:00:00 2001 From: Badlop Date: Tue, 16 Jun 2009 17:44:00 +0000 Subject: [PATCH] Deal with return values from starting/terminating supervisor (thanks to Stefan Strigler) SVN Revision: 2204 --- src/web/mod_http_bind.erl | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/web/mod_http_bind.erl b/src/web/mod_http_bind.erl index 34ed88722..4f590c659 100644 --- a/src/web/mod_http_bind.erl +++ b/src/web/mod_http_bind.erl @@ -75,17 +75,27 @@ process(_Path, _Request) -> %%% BEHAVIOUR CALLBACKS %%%---------------------------------------------------------------------- start(_Host, _Opts) -> - supervisor:start_child( - ejabberd_sup, - {ejabberd_http_bind_sup, - {ejabberd_tmp_sup, start_link, - [ejabberd_http_bind_sup, ejabberd_http_bind]}, - permanent, - infinity, - supervisor, - [ejabberd_tmp_sup]}), - ok. + HTTPBindSupervisor = + {ejabberd_http_bind_sup, + {ejabberd_tmp_sup, start_link, + [ejabberd_http_bind_sup, ejabberd_http_bind]}, + permanent, + infinity, + supervisor, + [ejabberd_tmp_sup]}, + case supervisor:start_child(ejabberd_sup, HTTPBindSupervisor) of + {ok, _Pid} -> + ok; + {ok, _Pid, _Info} -> + ok; + {error, Error} -> + {'EXIT', {start_child_error, Error}} + end. stop(_Host) -> - supervisor:terminate_child(ejabberd_sup, ejabberd_http_bind_sup), - ok. + case supervisor:terminate_child(ejabberd_sup, ejabberd_http_bind_sup) of + ok -> + ok; + {error, Error} -> + {'EXIT', {terminate_child_error, Error}} + end.