mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Fix error creating ETS table if enabled in several vhosts (EJAB-551). Unregister the command when stopping the module.
SVN Revision: 2173
This commit is contained in:
parent
2190055a06
commit
b416ed03c9
@ -165,25 +165,38 @@ loop(Filename) ->
|
|||||||
%%% BEHAVIOUR CALLBACKS
|
%%% BEHAVIOUR CALLBACKS
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
|
%% TODO: Improve this module to allow each virtual host to have a different
|
||||||
|
%% options. See http://support.process-one.net/browse/EJAB-561
|
||||||
start(_Host, Opts) ->
|
start(_Host, Opts) ->
|
||||||
ejabberd_ctl:register_commands([{"reopen-weblog", "reopen http fileserver log file"}],
|
case ets:info(mod_http_fileserver, name) of
|
||||||
?MODULE, ctl_process),
|
undefined ->
|
||||||
|
start2(_Host, Opts);
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
|
start2(_Host, Opts) ->
|
||||||
case gen_mod:get_opt(docroot, Opts, undefined) of
|
case gen_mod:get_opt(docroot, Opts, undefined) of
|
||||||
undefined ->
|
undefined ->
|
||||||
{'EXIT', {missing_document_root, ?MODULE}};
|
{'EXIT', {missing_document_root, ?MODULE}};
|
||||||
DocRoot ->
|
DocRoot ->
|
||||||
case filelib:is_dir(DocRoot) of
|
case filelib:is_dir(DocRoot) of
|
||||||
true ->
|
true ->
|
||||||
% XXX WARNING, using a single ets table name will
|
%% XXX WARNING, using a single ets table name will
|
||||||
% not work with virtual hosts
|
%% not work with virtual hosts
|
||||||
ets:new(mod_http_fileserver, [named_table, public]),
|
ets:new(mod_http_fileserver, [named_table, public]),
|
||||||
ets:insert(mod_http_fileserver, [{docroot, DocRoot}]),
|
ets:insert(mod_http_fileserver, [{docroot, DocRoot}]),
|
||||||
case gen_mod:get_opt(accesslog, Opts, undefined) of
|
case gen_mod:get_opt(accesslog, Opts, undefined) of
|
||||||
undefined ->
|
undefined ->
|
||||||
ok;
|
ok;
|
||||||
Filename ->
|
Filename ->
|
||||||
% XXX same remark as above for proc name
|
%% XXX same remark as above for proc name
|
||||||
register(mod_http_fileserver_server, spawn(?MODULE, loop, [Filename])),
|
ejabberd_ctl:register_commands(
|
||||||
|
[{"reopen-weblog",
|
||||||
|
"reopen http fileserver log file"}],
|
||||||
|
?MODULE, ctl_process),
|
||||||
|
register(mod_http_fileserver_server,
|
||||||
|
spawn(?MODULE, loop, [Filename])),
|
||||||
open_file(Filename)
|
open_file(Filename)
|
||||||
end;
|
end;
|
||||||
_Else ->
|
_Else ->
|
||||||
@ -200,6 +213,10 @@ stop(_Host) ->
|
|||||||
[] ->
|
[] ->
|
||||||
ok;
|
ok;
|
||||||
[{accessfile, AccessFile}] ->
|
[{accessfile, AccessFile}] ->
|
||||||
|
ejabberd_ctl:unregister_commands(
|
||||||
|
[{"reopen-weblog",
|
||||||
|
"reopen http fileserver log file"}],
|
||||||
|
?MODULE, ctl_process),
|
||||||
mod_http_fileserver_server ! stop,
|
mod_http_fileserver_server ! stop,
|
||||||
file:close(AccessFile)
|
file:close(AccessFile)
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user