mod_http_upload: Stop correct process name
Make sure the stop/1 function uses the same process name as the start/2 function.
This commit is contained in:
parent
31f19239d7
commit
f3bf402e7a
|
@ -94,11 +94,10 @@
|
||||||
%% gen_mod/supervisor callbacks.
|
%% gen_mod/supervisor callbacks.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-spec start_link(binary(), binary(), gen_mod:opts())
|
-spec start_link(binary(), atom(), gen_mod:opts())
|
||||||
-> {ok, pid()} | ignore | {error, _}.
|
-> {ok, pid()} | ignore | {error, _}.
|
||||||
|
|
||||||
start_link(ServerHost, ProcHost, Opts) ->
|
start_link(ServerHost, Proc, Opts) ->
|
||||||
Proc = gen_mod:get_module_proc(ProcHost, ?PROCNAME),
|
|
||||||
?GEN_SERVER:start_link({local, Proc}, ?MODULE, {ServerHost, Opts}, []).
|
?GEN_SERVER:start_link({local, Proc}, ?MODULE, {ServerHost, Opts}, []).
|
||||||
|
|
||||||
-spec start(binary(), gen_mod:opts()) -> {ok, _} | {ok, _, _} | {error, _}.
|
-spec start(binary(), gen_mod:opts()) -> {ok, _} | {ok, _, _} | {error, _}.
|
||||||
|
@ -114,18 +113,9 @@ start(ServerHost, Opts) ->
|
||||||
remove_user, 50);
|
remove_user, 50);
|
||||||
false -> ok
|
false -> ok
|
||||||
end,
|
end,
|
||||||
PutURL = gen_mod:get_opt(put_url, Opts,
|
Proc = get_proc_name(ServerHost),
|
||||||
fun(<<"http://", _/binary>> = URL) -> URL;
|
|
||||||
(<<"https://", _/binary>> = URL) -> URL;
|
|
||||||
(_) -> <<"http://@HOST@">>
|
|
||||||
end,
|
|
||||||
<<"http://@HOST@">>),
|
|
||||||
[_, ProcHost | _] = binary:split(expand_host(PutURL, ServerHost),
|
|
||||||
[<<"http://">>, <<"https://">>,
|
|
||||||
<<":">>, <<"/">>], [global]),
|
|
||||||
Proc = gen_mod:get_module_proc(ProcHost, ?PROCNAME),
|
|
||||||
Spec = {Proc,
|
Spec = {Proc,
|
||||||
{?MODULE, start_link, [ServerHost, ProcHost, Opts]},
|
{?MODULE, start_link, [ServerHost, Proc, Opts]},
|
||||||
permanent,
|
permanent,
|
||||||
3000,
|
3000,
|
||||||
worker,
|
worker,
|
||||||
|
@ -145,7 +135,7 @@ stop(ServerHost) ->
|
||||||
remove_user, 50);
|
remove_user, 50);
|
||||||
false -> ok
|
false -> ok
|
||||||
end,
|
end,
|
||||||
Proc = gen_mod:get_module_proc(ServerHost, ?PROCNAME),
|
Proc = get_proc_name(ServerHost),
|
||||||
ok = supervisor:terminate_child(ejabberd_sup, Proc),
|
ok = supervisor:terminate_child(ejabberd_sup, Proc),
|
||||||
ok = supervisor:delete_child(ejabberd_sup, Proc).
|
ok = supervisor:delete_child(ejabberd_sup, Proc).
|
||||||
|
|
||||||
|
@ -741,6 +731,22 @@ code_to_message(405) -> <<"Method not allowed.">>;
|
||||||
code_to_message(413) -> <<"File size doesn't match requested size.">>;
|
code_to_message(413) -> <<"File size doesn't match requested size.">>;
|
||||||
code_to_message(500) -> <<"Internal server error.">>.
|
code_to_message(500) -> <<"Internal server error.">>.
|
||||||
|
|
||||||
|
%% Miscellaneous helpers.
|
||||||
|
|
||||||
|
-spec get_proc_name(binary()) -> atom().
|
||||||
|
|
||||||
|
get_proc_name(ServerHost) ->
|
||||||
|
PutURL = gen_mod:get_module_opt(ServerHost, ?MODULE, put_url,
|
||||||
|
fun(<<"http://", _/binary>> = URL) -> URL;
|
||||||
|
(<<"https://", _/binary>> = URL) -> URL;
|
||||||
|
(_) -> <<"http://@HOST@">>
|
||||||
|
end,
|
||||||
|
<<"http://@HOST@">>),
|
||||||
|
[_, ProcHost | _] = binary:split(expand_host(PutURL, ServerHost),
|
||||||
|
[<<"http://">>, <<"https://">>,
|
||||||
|
<<":">>, <<"/">>], [global]),
|
||||||
|
gen_mod:get_module_proc(ProcHost, ?PROCNAME).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Remove user.
|
%% Remove user.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue