diff --git a/ejabberd-dev/include/adhoc.hrl b/ejabberd-dev/include/adhoc.hrl index 45c74ca..b294f84 100644 --- a/ejabberd-dev/include/adhoc.hrl +++ b/ejabberd-dev/include/adhoc.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2012 ProcessOne +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/ejabberd-dev/include/ejabberd.hrl b/ejabberd-dev/include/ejabberd.hrl index 7d1f554..6edd5b8 100644 --- a/ejabberd-dev/include/ejabberd.hrl +++ b/ejabberd-dev/include/ejabberd.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2012 ProcessOne +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/ejabberd-dev/include/ejabberd_commands.hrl b/ejabberd-dev/include/ejabberd_commands.hrl index 5798a6b..1ababc8 100644 --- a/ejabberd-dev/include/ejabberd_commands.hrl +++ b/ejabberd-dev/include/ejabberd_commands.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2012 ProcessOne +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/ejabberd-dev/include/ejabberd_config.hrl b/ejabberd-dev/include/ejabberd_config.hrl index 4cacd36..b0fa46a 100644 --- a/ejabberd-dev/include/ejabberd_config.hrl +++ b/ejabberd-dev/include/ejabberd_config.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2012 ProcessOne +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/ejabberd-dev/include/ejabberd_ctl.hrl b/ejabberd-dev/include/ejabberd_ctl.hrl index d715134..27bb248 100644 --- a/ejabberd-dev/include/ejabberd_ctl.hrl +++ b/ejabberd-dev/include/ejabberd_ctl.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2012 ProcessOne +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/ejabberd-dev/include/jlib.hrl b/ejabberd-dev/include/jlib.hrl index ae5862d..0e5c832 100644 --- a/ejabberd-dev/include/jlib.hrl +++ b/ejabberd-dev/include/jlib.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2012 ProcessOne +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/ejabberd-dev/include/mod_muc/mod_muc_room.hrl b/ejabberd-dev/include/mod_muc/mod_muc_room.hrl index a7a6ca0..523df34 100644 --- a/ejabberd-dev/include/mod_muc/mod_muc_room.hrl +++ b/ejabberd-dev/include/mod_muc/mod_muc_room.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2012 ProcessOne +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/ejabberd-dev/include/mod_pubsub/pubsub.hrl b/ejabberd-dev/include/mod_pubsub/pubsub.hrl index 8cc20c4..552d507 100644 --- a/ejabberd-dev/include/mod_pubsub/pubsub.hrl +++ b/ejabberd-dev/include/mod_pubsub/pubsub.hrl @@ -11,12 +11,12 @@ %%% under the License. %%% %%% The Initial Developer of the Original Code is ProcessOne. -%%% Portions created by ProcessOne are Copyright 2006-2011, ProcessOne +%%% Portions created by ProcessOne are Copyright 2006-2013, ProcessOne %%% All Rights Reserved.'' -%%% This software is copyright 2006-2011, ProcessOne. +%%% This software is copyright 2006-2013, ProcessOne. %%% %%% -%%% copyright 2006-2011 ProcessOne +%%% copyright 2006-2013 ProcessOne %%% %%% This file contains pubsub types definition. %%% ==================================================================== @@ -136,8 +136,9 @@ options = [] }). -%% @type pubsubState() = {pubsub_state, StateId, Items, Affiliation, Subscriptions} +%% @type pubsubState() = {pubsub_state, StateId, NodeIdx, Items, Affiliation, Subscriptions} %% StateId = {ljid(), nodeIdx()} +%% NodeIdx = nodeIdx(), %% Items = [itemId()] %% Affiliation = affiliation() %% Subscriptions = [{subscription(), subId()}]. @@ -146,6 +147,7 @@ -record(pubsub_state, { stateid, + nodeidx, items = [], affiliation = 'none', subscriptions = [] @@ -161,6 +163,7 @@ -record(pubsub_item, { itemid, + nodeidx, creation = {'unknown','unknown'}, modification = {'unknown','unknown'}, payload = [] diff --git a/ejabberd-dev/include/mod_roster.hrl b/ejabberd-dev/include/mod_roster.hrl index 7e1acaa..2fc2c76 100644 --- a/ejabberd-dev/include/mod_roster.hrl +++ b/ejabberd-dev/include/mod_roster.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2012 ProcessOne +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/ejabberd-dev/include/web/ejabberd_http.hrl b/ejabberd-dev/include/web/ejabberd_http.hrl index 7cd6da1..4f3dd17 100644 --- a/ejabberd-dev/include/web/ejabberd_http.hrl +++ b/ejabberd-dev/include/web/ejabberd_http.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2012 ProcessOne +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/ejabberd-dev/include/web/ejabberd_web_admin.hrl b/ejabberd-dev/include/web/ejabberd_web_admin.hrl index 73f792e..646e1c1 100644 --- a/ejabberd-dev/include/web/ejabberd_web_admin.hrl +++ b/ejabberd-dev/include/web/ejabberd_web_admin.hrl @@ -1,6 +1,6 @@ %%%---------------------------------------------------------------------- %%% -%%% ejabberd, Copyright (C) 2002-2012 ProcessOne +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as diff --git a/ejabberd-dev/src/gen_mod.erl b/ejabberd-dev/src/gen_mod.erl index 49f4991..c9fdceb 100644 --- a/ejabberd-dev/src/gen_mod.erl +++ b/ejabberd-dev/src/gen_mod.erl @@ -5,7 +5,7 @@ %%% Created : 24 Jan 2003 by Alexey Shchepin %%% %%% -%%% ejabberd, Copyright (C) 2002-2008 ProcessOne +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -16,7 +16,7 @@ %%% but WITHOUT ANY WARRANTY; without even the implied warranty of %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %%% General Public License for more details. -%%% +%%% %%% You should have received a copy of the GNU General Public License %%% along with this program; if not, write to the Free Software %%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA @@ -34,6 +34,8 @@ get_opt/2, get_opt/3, get_opt_host/3, + db_type/1, + db_type/2, get_module_opt/4, get_module_opt_host/3, loaded_modules/1, @@ -66,15 +68,28 @@ start_module(Host, Module, Opts) -> ets:insert(ejabberd_modules, #ejabberd_module{module_host = {Module, Host}, opts = Opts}), - case catch Module:start(Host, Opts) of - {'EXIT', Reason} -> + try Module:start(Host, Opts) + catch Class:Reason -> del_module_mnesia(Host, Module), ets:delete(ejabberd_modules, {Module, Host}), - ?ERROR_MSG("~p", [Reason]); - _ -> - ok + ErrorText = io_lib:format("Problem starting the module ~p for host ~p ~n options: ~p~n ~p: ~p", + [Module, Host, Opts, Class, Reason]), + ?CRITICAL_MSG(ErrorText, []), + case is_app_running(ejabberd) of + true -> + erlang:raise(Class, Reason, erlang:get_stacktrace()); + false -> + ?CRITICAL_MSG("ejabberd initialization was aborted because a module start failed.", []), + timer:sleep(3000), + erlang:halt(string:substr(lists:flatten(ErrorText), 1, 199)) + end end. +is_app_running(AppName) -> + %% Use a high timeout to prevent a false positive in a high load system + Timeout = 15000, + lists:keymember(AppName, 1, application:which_applications(Timeout)). + %% @doc Stop the module in a host, and forget its configuration. stop_module(Host, Module) -> case stop_module_keep_config(Host, Module) of @@ -173,11 +188,23 @@ get_module_opt(Host, Module, Opt, Default) -> get_module_opt_host(Host, Module, Default) -> Val = get_module_opt(Host, Module, host, Default), - element(2, regexp:gsub(Val, "@HOST@", Host)). + ejabberd_regexp:greplace(Val, "@HOST@", Host). get_opt_host(Host, Opts, Default) -> Val = get_opt(host, Opts, Default), - element(2, regexp:gsub(Val, "@HOST@", Host)). + ejabberd_regexp:greplace(Val, "@HOST@", Host). + +db_type(Opts) -> + case get_opt(db_type, Opts, mnesia) of + odbc -> odbc; + _ -> mnesia + end. + +db_type(Host, Module) -> + case get_module_opt(Host, Module, db_type, mnesia) of + odbc -> odbc; + _ -> mnesia + end. loaded_modules(Host) -> ets:select(ejabberd_modules,