mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Only use GEN_SERVER macro where appropriate
This commit is contained in:
parent
28f66ddd7c
commit
f61c933a7a
@ -27,7 +27,10 @@
|
||||
|
||||
-author('alexey@process-one.net').
|
||||
|
||||
-behaviour(gen_server).
|
||||
-ifndef(GEN_SERVER).
|
||||
-define(GEN_SERVER, gen_server).
|
||||
-endif.
|
||||
-behaviour(?GEN_SERVER).
|
||||
|
||||
%% API
|
||||
-export([start_link/4,
|
||||
@ -65,7 +68,7 @@
|
||||
{ok, pid()}.
|
||||
|
||||
start_link(Socket, SockMod, Shaper, MaxStanzaSize) ->
|
||||
gen_server:start_link(?MODULE,
|
||||
?GEN_SERVER:start_link(?MODULE,
|
||||
[Socket, SockMod, Shaper, MaxStanzaSize], []).
|
||||
|
||||
-spec start(inet:socket(), atom(), shaper:shaper()) -> undefined | pid().
|
||||
@ -77,14 +80,14 @@ start(Socket, SockMod, Shaper) ->
|
||||
non_neg_integer() | infinity) -> undefined | pid().
|
||||
|
||||
start(Socket, SockMod, Shaper, MaxStanzaSize) ->
|
||||
{ok, Pid} = gen_server:start(ejabberd_receiver,
|
||||
{ok, Pid} = ?GEN_SERVER:start(ejabberd_receiver,
|
||||
[Socket, SockMod, Shaper, MaxStanzaSize], []),
|
||||
Pid.
|
||||
|
||||
-spec change_shaper(pid(), shaper:shaper()) -> ok.
|
||||
|
||||
change_shaper(Pid, Shaper) ->
|
||||
gen_server:cast(Pid, {change_shaper, Shaper}).
|
||||
?GEN_SERVER:cast(Pid, {change_shaper, Shaper}).
|
||||
|
||||
-spec reset_stream(pid()) -> ok | {error, any()}.
|
||||
|
||||
@ -109,7 +112,7 @@ become_controller(Pid, C2SPid) ->
|
||||
-spec close(pid()) -> ok.
|
||||
|
||||
close(Pid) ->
|
||||
gen_server:cast(Pid, close).
|
||||
?GEN_SERVER:cast(Pid, close).
|
||||
|
||||
|
||||
%%====================================================================
|
||||
@ -220,7 +223,7 @@ handle_info({timeout, _Ref, activate}, State) ->
|
||||
activate_socket(State),
|
||||
{noreply, State, ?HIBERNATE_TIMEOUT};
|
||||
handle_info(timeout, State) ->
|
||||
proc_lib:hibernate(gen_server, enter_loop,
|
||||
proc_lib:hibernate(?GEN_SERVER, enter_loop,
|
||||
[?MODULE, [], State]),
|
||||
{noreply, State, ?HIBERNATE_TIMEOUT};
|
||||
handle_info(_Info, State) ->
|
||||
@ -335,7 +338,7 @@ do_send(State, Data) ->
|
||||
(State#state.sock_mod):send(State#state.socket, Data).
|
||||
|
||||
do_call(Pid, Msg) ->
|
||||
case catch gen_server:call(Pid, Msg) of
|
||||
case catch ?GEN_SERVER:call(Pid, Msg) of
|
||||
{'EXIT', Why} -> {error, Why};
|
||||
Res -> Res
|
||||
end.
|
||||
|
@ -29,7 +29,10 @@
|
||||
|
||||
-author('alexey@process-one.net').
|
||||
|
||||
-behaviour(gen_server).
|
||||
-ifndef(GEN_SERVER).
|
||||
-define(GEN_SERVER, gen_server).
|
||||
-endif.
|
||||
-behaviour(?GEN_SERVER).
|
||||
|
||||
%% API
|
||||
-export([route/3,
|
||||
@ -77,7 +80,7 @@ start() ->
|
||||
supervisor:start_child(ejabberd_sup, ChildSpec).
|
||||
|
||||
start_link() ->
|
||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||
?GEN_SERVER:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||
|
||||
-spec route(jid(), jid(), xmlel() | stanza()) -> ok.
|
||||
route(#jid{} = From, #jid{} = To, #xmlel{} = El) ->
|
||||
|
@ -29,7 +29,10 @@
|
||||
|
||||
-author('alexey@process-one.net').
|
||||
|
||||
-behaviour(gen_server).
|
||||
-ifndef(GEN_SERVER).
|
||||
-define(GEN_SERVER, gen_server).
|
||||
-endif.
|
||||
-behaviour(?GEN_SERVER).
|
||||
|
||||
%% API
|
||||
-export([start/0,
|
||||
@ -110,7 +113,7 @@ start() ->
|
||||
supervisor:start_child(ejabberd_sup, ChildSpec).
|
||||
|
||||
start_link() ->
|
||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||
?GEN_SERVER:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||
|
||||
-spec route(jid(), term()) -> ok.
|
||||
%% @doc route arbitrary term to c2s process(es)
|
||||
@ -358,13 +361,13 @@ get_vh_session_number(Server) ->
|
||||
-spec register_iq_handler(binary(), binary(), atom(), atom(), list()) -> ok.
|
||||
|
||||
register_iq_handler(Host, XMLNS, Module, Fun, Opts) ->
|
||||
gen_server:cast(?MODULE,
|
||||
?GEN_SERVER:cast(?MODULE,
|
||||
{register_iq_handler, Host, XMLNS, Module, Fun, Opts}).
|
||||
|
||||
-spec unregister_iq_handler(binary(), binary()) -> ok.
|
||||
|
||||
unregister_iq_handler(Host, XMLNS) ->
|
||||
gen_server:cast(?MODULE, {unregister_iq_handler, Host, XMLNS}).
|
||||
?GEN_SERVER:cast(?MODULE, {unregister_iq_handler, Host, XMLNS}).
|
||||
|
||||
%% Why the hell do we have so many similar kicks?
|
||||
c2s_handle_info(#{lang := Lang} = State, replaced) ->
|
||||
|
@ -27,7 +27,10 @@
|
||||
|
||||
-author('alexey@process-one.net').
|
||||
|
||||
-behaviour(gen_server).
|
||||
-ifndef(GEN_SERVER).
|
||||
-define(GEN_SERVER, gen_server).
|
||||
-endif.
|
||||
-behaviour(?GEN_SERVER).
|
||||
|
||||
%% API
|
||||
-export([start_link/3, add_iq_handler/6,
|
||||
@ -57,7 +60,7 @@
|
||||
%% Description: Starts the server
|
||||
%%--------------------------------------------------------------------
|
||||
start_link(Host, Module, Function) ->
|
||||
gen_server:start_link(?MODULE, [Host, Module, Function],
|
||||
?GEN_SERVER:start_link(?MODULE, [Host, Module, Function],
|
||||
[]).
|
||||
|
||||
-spec add_iq_handler(module(), binary(), binary(), module(), atom(), type()) -> ok.
|
||||
@ -98,10 +101,10 @@ remove_iq_handler(Component, Host, NS) ->
|
||||
|
||||
stop_iq_handler(_Module, _Function, Opts) ->
|
||||
case Opts of
|
||||
{one_queue, Pid} -> gen_server:call(Pid, stop);
|
||||
{one_queue, Pid} -> ?GEN_SERVER:call(Pid, stop);
|
||||
{queues, Pids} ->
|
||||
lists:foreach(fun (Pid) ->
|
||||
catch gen_server:call(Pid, stop)
|
||||
catch ?GEN_SERVER:call(Pid, stop)
|
||||
end,
|
||||
Pids);
|
||||
_ -> ok
|
||||
|
@ -28,9 +28,6 @@
|
||||
|
||||
-protocol({xep, 363, '0.1'}).
|
||||
|
||||
-ifndef(GEN_SERVER).
|
||||
-define(GEN_SERVER, gen_server).
|
||||
-endif.
|
||||
-define(SERVICE_REQUEST_TIMEOUT, 5000). % 5 seconds.
|
||||
-define(SLOT_TIMEOUT, 18000000). % 5 hours.
|
||||
-define(FORMAT(Error), file:format_error(Error)).
|
||||
@ -62,7 +59,7 @@
|
||||
{<<".xz">>, <<"application/x-xz">>},
|
||||
{<<".zip">>, <<"application/zip">>}]).
|
||||
|
||||
-behaviour(?GEN_SERVER).
|
||||
-behaviour(gen_server).
|
||||
-behaviour(gen_mod).
|
||||
|
||||
%% gen_mod/supervisor callbacks.
|
||||
|
@ -26,14 +26,11 @@
|
||||
-module(mod_http_upload_quota).
|
||||
-author('holger@zedat.fu-berlin.de').
|
||||
|
||||
-ifndef(GEN_SERVER).
|
||||
-define(GEN_SERVER, gen_server).
|
||||
-endif.
|
||||
-define(TIMEOUT, timer:hours(24)).
|
||||
-define(INITIAL_TIMEOUT, timer:minutes(10)).
|
||||
-define(FORMAT(Error), file:format_error(Error)).
|
||||
|
||||
-behaviour(?GEN_SERVER).
|
||||
-behaviour(gen_server).
|
||||
-behaviour(gen_mod).
|
||||
|
||||
%% gen_mod/supervisor callbacks.
|
||||
@ -253,7 +250,7 @@ code_change(_OldVsn, #state{server_host = ServerHost} = State, _Extra) ->
|
||||
handle_slot_request(allow, #jid{lserver = ServerHost} = JID, Path, Size,
|
||||
_Lang) ->
|
||||
Proc = mod_http_upload:get_proc_name(ServerHost, ?MODULE),
|
||||
?GEN_SERVER:cast(Proc, {handle_slot_request, JID, Path, Size}),
|
||||
gen_server:cast(Proc, {handle_slot_request, JID, Path, Size}),
|
||||
allow;
|
||||
handle_slot_request(Acc, _JID, _Path, _Size, _Lang) -> Acc.
|
||||
|
||||
|
@ -33,11 +33,7 @@
|
||||
-protocol({xep, 160, '1.0'}).
|
||||
-protocol({xep, 334, '0.2'}).
|
||||
|
||||
-ifndef(GEN_SERVER).
|
||||
-define(GEN_SERVER, gen_server).
|
||||
-endif.
|
||||
-behaviour(?GEN_SERVER).
|
||||
|
||||
-behaviour(gen_server).
|
||||
-behaviour(gen_mod).
|
||||
|
||||
-export([start/2,
|
||||
|
Loading…
Reference in New Issue
Block a user