mod_http_fileserver: Unregister 'reopen_log_hook'

Unregister the global 'reopen_log_hook' on termination if the module isn't
loaded for another host.
This commit is contained in:
Holger Weiss 2019-07-14 15:16:13 +02:00
parent 15dcff92e8
commit cd36bb6eda
1 changed files with 7 additions and 4 deletions

View File

@ -243,11 +243,14 @@ handle_info(Info, State) ->
%% cleaning up. When it returns, the gen_server terminates with Reason.
%% The return value is ignored.
%%--------------------------------------------------------------------
terminate(_Reason, State) ->
terminate(_Reason, #state{host = Host} = State) ->
close_log(State#state.accesslogfd),
%% TODO: unregister the hook gracefully
%% ejabberd_hooks:delete(reopen_log_hook, State#state.host, ?MODULE, reopen_log, 50),
ok.
case gen_mod:is_loaded_elsewhere(Host, ?MODULE) of
false ->
ejabberd_hooks:delete(reopen_log_hook, ?MODULE, reopen_log, 50);
true ->
ok
end.
%%--------------------------------------------------------------------
%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}