From 24ab5026c929b2d4e4fd2e2397e54b84262b4bb5 Mon Sep 17 00:00:00 2001 From: Badlop Date: Tue, 16 Jun 2009 18:27:10 +0000 Subject: [PATCH] Changed the place where database is created(thanks to Michael Remond) SVN Revision: 2312 --- src/web/ejabberd_http_bind.erl | 19 +------------------ src/web/mod_http_bind.erl | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/web/ejabberd_http_bind.erl b/src/web/ejabberd_http_bind.erl index cdb8ecac9..e55b840cb 100644 --- a/src/web/ejabberd_http_bind.erl +++ b/src/web/ejabberd_http_bind.erl @@ -4,7 +4,7 @@ %%% Purpose : Implements XMPP over BOSH (XEP-0205) (formerly known as %%% HTTP Binding) %%% Created : 21 Sep 2005 by Stefan Strigler -%%% Id : $Id: ejabberd_http_bind.erl 917 2009-03-13 16:27:30Z badlop $ +%%% Id : $Id: ejabberd_http_bind.erl 942 2009-04-22 15:25:31Z mremond $ %%%---------------------------------------------------------------------- -module(ejabberd_http_bind). @@ -95,7 +95,6 @@ %%% API %%%---------------------------------------------------------------------- start(Sid, Key, IP) -> - setup_database(), supervisor:start_child(ejabberd_http_bind_sup, [Sid, Key, IP]). start_link(Sid, Key, IP) -> @@ -1110,19 +1109,3 @@ check_default_xmlns({xmlelement, Name, Attrs, Els} = El) -> true -> El end. - -setup_database() -> - migrate_database(), - mnesia:create_table(http_bind, - [{ram_copies, [node()]}, - {attributes, record_info(fields, http_bind)}]). - -migrate_database() -> - case catch mnesia:table_info(http_bind, attributes) of - [id, pid, to, hold, wait, version] -> - ok; - _ -> - %% Since the stored information is not important, instead - %% of actually migrating data, let's just destroy the table - mnesia:delete_table(http_bind) - end. diff --git a/src/web/mod_http_bind.erl b/src/web/mod_http_bind.erl index 0e238f1f7..68688e328 100644 --- a/src/web/mod_http_bind.erl +++ b/src/web/mod_http_bind.erl @@ -3,7 +3,7 @@ %%% Author : Stefan Strigler %%% Purpose : Implementation of XMPP over BOSH (XEP-0206) %%% Created : Tue Feb 20 13:15:52 CET 2007 -%%% Id : $Id: mod_http_bind.erl 856 2009-01-13 17:11:02Z badlop $ +%%% Id : $Id: mod_http_bind.erl 942 2009-04-22 15:25:31Z mremond $ %%%---------------------------------------------------------------------- %%%---------------------------------------------------------------------- @@ -31,6 +31,9 @@ -include("jlib.hrl"). -include("ejabberd_http.hrl"). +%% Duplicated from ejabberd_http_bind. +%% TODO: move to hrl file. +-record(http_bind, {id, pid, to, hold, wait, version}). %%%---------------------------------------------------------------------- %%% API @@ -69,6 +72,7 @@ process(_Path, _Request) -> %%% BEHAVIOUR CALLBACKS %%%---------------------------------------------------------------------- start(_Host, _Opts) -> + setup_database(), HTTPBindSupervisor = {ejabberd_http_bind_sup, {ejabberd_tmp_sup, start_link, @@ -96,3 +100,19 @@ stop(_Host) -> {error, Error} -> {'EXIT', {terminate_child_error, Error}} end. + +setup_database() -> + migrate_database(), + mnesia:create_table(http_bind, + [{ram_copies, [node()]}, + {attributes, record_info(fields, http_bind)}]). + +migrate_database() -> + case catch mnesia:table_info(http_bind, attributes) of + [id, pid, to, hold, wait, version] -> + ok; + _ -> + %% Since the stored information is not important, instead + %% of actually migrating data, let's just destroy the table + mnesia:delete_table(http_bind) + end.