mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
New optional BOSH connection attribute process-delay (EJAB-1257)
This commit is contained in:
parent
4e459b9466
commit
bc1b4163a2
@ -47,7 +47,7 @@
|
|||||||
-include("http_bind.hrl").
|
-include("http_bind.hrl").
|
||||||
-include_lib("exmpp/include/exmpp.hrl").
|
-include_lib("exmpp/include/exmpp.hrl").
|
||||||
|
|
||||||
-record(http_bind, {id, pid, to, hold, wait, version}).
|
-record(http_bind, {id, pid, to, hold, wait, process_delay, version}).
|
||||||
|
|
||||||
-define(NULL_PEER, {{0, 0, 0, 0}, 0}).
|
-define(NULL_PEER, {{0, 0, 0, 0}, 0}).
|
||||||
|
|
||||||
@ -106,6 +106,11 @@
|
|||||||
-define(MAX_PAUSE, 120). % may num of sec a client is allowed to pause
|
-define(MAX_PAUSE, 120). % may num of sec a client is allowed to pause
|
||||||
% the session
|
% the session
|
||||||
|
|
||||||
|
%% Wait 100ms before continue processing, to allow the client provide more related stanzas.
|
||||||
|
-define(PROCESS_DELAY_DEFAULT, 100).
|
||||||
|
-define(PROCESS_DELAY_MIN, 0).
|
||||||
|
-define(PROCESS_DELAY_MAX, 1000).
|
||||||
|
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% API
|
%%% API
|
||||||
@ -276,6 +281,18 @@ handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs,
|
|||||||
CHold
|
CHold
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
Pdelay = case string:to_integer(xml:get_attr_s("process-delay",Attrs)) of
|
||||||
|
{error, _} ->
|
||||||
|
?PROCESS_DELAY_DEFAULT;
|
||||||
|
{CPdelay, _} when
|
||||||
|
(?PROCESS_DELAY_MIN =< CPdelay) and
|
||||||
|
(CPdelay =< ?PROCESS_DELAY_MAX) ->
|
||||||
|
CPdelay;
|
||||||
|
{CPdelay, _} ->
|
||||||
|
erlang:max(
|
||||||
|
erlang:min(CPdelay,?PROCESS_DELAY_MAX),
|
||||||
|
?PROCESS_DELAY_MIN)
|
||||||
|
end,
|
||||||
Version =
|
Version =
|
||||||
case catch list_to_float(
|
case catch list_to_float(
|
||||||
exmpp_xml:get_attribute_from_list_as_list(Attrs, "ver", "")) of
|
exmpp_xml:get_attribute_from_list_as_list(Attrs, "ver", "")) of
|
||||||
@ -293,6 +310,7 @@ handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs,
|
|||||||
XmppVersion},
|
XmppVersion},
|
||||||
hold = Hold,
|
hold = Hold,
|
||||||
wait = Wait,
|
wait = Wait,
|
||||||
|
process_delay = Pdelay,
|
||||||
version = Version
|
version = Version
|
||||||
})
|
})
|
||||||
end),
|
end),
|
||||||
@ -946,6 +964,7 @@ update_shaper(ShaperState, PayloadSize) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
prepare_response(Sess, Rid, OutputEls, StreamStart) ->
|
prepare_response(Sess, Rid, OutputEls, StreamStart) ->
|
||||||
|
receive after Sess#http_bind.process_delay -> ok end,
|
||||||
case catch http_get(Sess, Rid) of
|
case catch http_get(Sess, Rid) of
|
||||||
{ok, cancel} ->
|
{ok, cancel} ->
|
||||||
%% actually it would be better if we could completely
|
%% actually it would be better if we could completely
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
%% Duplicated from ejabberd_http_bind.
|
%% Duplicated from ejabberd_http_bind.
|
||||||
%% TODO: move to hrl file.
|
%% TODO: move to hrl file.
|
||||||
-record(http_bind, {id, pid, to, hold, wait, version}).
|
-record(http_bind, {id, pid, to, hold, wait, process_delay, version}).
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% API
|
%%% API
|
||||||
@ -143,7 +143,7 @@ setup_database() ->
|
|||||||
|
|
||||||
migrate_database() ->
|
migrate_database() ->
|
||||||
case catch mnesia:table_info(http_bind, attributes) of
|
case catch mnesia:table_info(http_bind, attributes) of
|
||||||
[id, pid, to, hold, wait, version] ->
|
[id, pid, to, hold, wait, process_delay, version] ->
|
||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
%% Since the stored information is not important, instead
|
%% Since the stored information is not important, instead
|
||||||
|
Loading…
Reference in New Issue
Block a user