25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

* src/mod_proxy65/mod_proxy65.erl: Update so the listener starts

correctly (EJAB-303)
* src/mod_proxy65/mod_proxy65_service.erl: Likewise

SVN Revision: 1632
This commit is contained in:
Badlop 2008-10-12 11:17:35 +00:00
parent 9194c25a4e
commit be2f6e0517
3 changed files with 38 additions and 15 deletions

View File

@ -1,5 +1,9 @@
2008-10-12 Badlop <badlop@process-one.net>
* src/mod_proxy65/mod_proxy65.erl: Update so the listener starts
correctly (EJAB-303)
* src/mod_proxy65/mod_proxy65_service.erl: Likewise
* src/ejabberd_app.erl: Start listeners explicitely at server
start after everything else (EJAB-303). Implement support in
ejabberd for 'independent listeners', which handle their

View File

@ -42,6 +42,7 @@
-define(PROCNAME, ejabberd_mod_proxy65).
start(Host, Opts) ->
mod_proxy65_service:add_listener(Host, Opts),
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
ChildSpec = {
Proc, {?MODULE, start_link, [Host, Opts]},
@ -50,6 +51,7 @@ start(Host, Opts) ->
supervisor:start_child(ejabberd_sup, ChildSpec).
stop(Host) ->
mod_proxy65_service:delete_listener(Host),
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
supervisor:terminate_child(ejabberd_sup, Proc),
supervisor:delete_child(ejabberd_sup, Proc).

View File

@ -39,7 +39,7 @@
]).
%% API.
-export([start_link/2]).
-export([start_link/2, add_listener/2, delete_listener/1]).
-include("ejabberd.hrl").
-include("jlib.hrl").
@ -55,28 +55,21 @@
acl
}).
%% Unused callbacks.
handle_cast(_Request, State) ->
{noreply, State}.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
handle_call(_Request, _From, State) ->
{reply, ok, State}.
%%----------------
%%%------------------------
%%% gen_server callbacks
%%%------------------------
start_link(Host, Opts) ->
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
gen_server:start_link({local, Proc}, ?MODULE, [Host, Opts], []).
init([Host, Opts]) ->
{IP, State} = parse_options(Host, Opts),
NewOpts = [Host, {ip, IP} | Opts],
ejabberd_listener:add_listener(State#state.port, mod_proxy65_stream, NewOpts),
{_IP, State} = parse_options(Host, Opts),
ejabberd_router:register_route(State#state.myhost),
{ok, State}.
terminate(_Reason, #state{myhost=MyHost, port=Port}) ->
catch ejabberd_listener:delete_listener(Port),
terminate(_Reason, #state{myhost=MyHost}) ->
ejabberd_router:unregister_route(MyHost),
ok.
@ -93,10 +86,34 @@ handle_info({route, From, To, {xmlelement, "iq", _, _} = Packet}, State) ->
ok
end,
{noreply, State};
handle_info(_Info, State) ->
{noreply, State}.
handle_call(get_port, _From, State) ->
{reply, {port, State#state.port}, State};
handle_call(_Request, _From, State) ->
{reply, ok, State}.
handle_cast(_Request, State) ->
{noreply, State}.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
%%%------------------------
%%% Listener management
%%%------------------------
add_listener(Host, Opts) ->
{IP, State} = parse_options(Host, Opts),
NewOpts = [Host, {ip, IP} | Opts],
ejabberd_listener:add_listener(State#state.port,mod_proxy65_stream,NewOpts).
delete_listener(Host) ->
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
{port, Port} = gen_server:call(Proc, get_port),
catch ejabberd_listener:delete_listener(Port, mod_proxy65_stream).
%%%------------------------
%%% IQ Processing
%%%------------------------