25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

* src/odbc/ejabberd_odbc.erl: Load-balance ODBC requests between

several connections

* src/odbc/ejabberd_odbc_sup.erl: Supervisor for ODBC connections

* src/mod_muc/mod_muc_room.erl: Added missed type='form' attribute
in room configuration response (thanks to Badlop)

SVN Revision: 295
This commit is contained in:
Alexey Shchepin 2004-12-29 23:10:14 +00:00
parent 50bef3787a
commit 3416cbe63a
4 changed files with 64 additions and 4 deletions

View File

@ -1,3 +1,13 @@
2004-12-30 Alexey Shchepin <alexey@sevcom.net>
* src/odbc/ejabberd_odbc.erl: Load-balance ODBC requests between
several connections
* src/odbc/ejabberd_odbc_sup.erl: Supervisor for ODBC connections
* src/mod_muc/mod_muc_room.erl: Added missed type='form' attribute
in room configuration response (thanks to Badlop)
2004-12-19 Alexey Shchepin <alexey@sevcom.net> 2004-12-19 Alexey Shchepin <alexey@sevcom.net>
* src/mod_roster_odbc.erl: Roster support via ODBC (not completed) * src/mod_roster_odbc.erl: Roster support via ODBC (not completed)

View File

@ -1970,7 +1970,10 @@ get_config(Lang, StateData) ->
[{xmlcdata, [{xmlcdata,
translate:translate( translate:translate(
Lang, "You need an x:data capable client to configure room")}]}, Lang, "You need an x:data capable client to configure room")}]},
{xmlelement, "x", [{"xmlns", ?NS_XDATA}], Res}], StateData}. {xmlelement, "x", [{"xmlns", ?NS_XDATA},
{"type", "form"}],
Res}],
StateData}.

View File

@ -31,13 +31,14 @@
%%% API %%% API
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
start() -> start() ->
gen_server:start({local, ejabberd_odbc}, ejabberd_odbc, [], []). gen_server:start(ejabberd_odbc, [], []).
start_link() -> start_link() ->
gen_server:start_link({local, ejabberd_odbc}, ejabberd_odbc, [], []). gen_server:start_link(ejabberd_odbc, [], []).
sql_query(Query) -> sql_query(Query) ->
gen_server:call(ejabberd_odbc, {sql_query, Query}, 60000). gen_server:call(ejabberd_odbc_sup:get_random_pid(),
{sql_query, Query}, 60000).
escape(S) -> escape(S) ->
[case C of [case C of

View File

@ -0,0 +1,46 @@
%%%----------------------------------------------------------------------
%%% File : ejabberd_odbc_sup.erl
%%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose : ODBC connections supervisor
%%% Created : 22 Dec 2004 by Alexey Shchepin <alexey@sevcom.net>
%%% Id : $Id$
%%%----------------------------------------------------------------------
-module(ejabberd_odbc_sup).
-author('alexey@sevcom.net').
-vsn('$Revision$ ').
-export([start_link/0,
init/1,
get_pids/0,
get_random_pid/0
]).
-include("ejabberd.hrl").
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init(_) ->
% TODO
N = 10,
{ok, {{one_for_one, 10, 1},
lists:map(
fun(I) ->
{I,
{ejabberd_odbc, start_link, []},
transient,
brutal_kill,
worker,
[?MODULE]}
end, lists:seq(1, N))}}.
get_pids() ->
[Child ||
{_Id, Child, _Type, _Modules} <- supervisor:which_children(?MODULE),
Child /= undefined].
get_random_pid() ->
Pids = get_pids(),
lists:nth(erlang:phash(now(), length(Pids)), Pids).