summaryrefslogtreecommitdiff
path: root/src/web/ejabberd_http_bind.erl
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2010-06-07 13:44:55 +0200
committerBadlop <badlop@process-one.net>2010-06-07 13:44:55 +0200
commitd4ec7a2f01f35793c05442165166561c9f9b1f29 (patch)
tree43e0808443b63653533ca2fb7d7511b1ef4a54dc /src/web/ejabberd_http_bind.erl
parentRevert version number from 2.1.4 tag to 2.1.x branch (diff)
New optional BOSH connection attribute process-delay (EJAB-1257)
Diffstat (limited to 'src/web/ejabberd_http_bind.erl')
-rw-r--r--src/web/ejabberd_http_bind.erl21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/web/ejabberd_http_bind.erl b/src/web/ejabberd_http_bind.erl
index 6f15703e..80ddaf3e 100644
--- a/src/web/ejabberd_http_bind.erl
+++ b/src/web/ejabberd_http_bind.erl
@@ -45,7 +45,7 @@
-include("ejabberd_http.hrl").
-include("http_bind.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}).
@@ -107,6 +107,11 @@
-define(MAX_PAUSE, 120). % may num of sec a client is allowed to pause
% 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
@@ -257,6 +262,18 @@ handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs,
CHold
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 =
case catch list_to_float(
xml:get_attr_s("ver", Attrs)) of
@@ -274,6 +291,7 @@ handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs,
XmppVersion},
hold = Hold,
wait = Wait,
+ process_delay = Pdelay,
version = Version
})
end),
@@ -884,6 +902,7 @@ update_shaper(ShaperState, PayloadSize) ->
end.
prepare_response(Sess, Rid, OutputEls, StreamStart) ->
+ receive after Sess#http_bind.process_delay -> ok end,
case catch http_get(Sess, Rid) of
{ok, cancel} ->
%% actually it would be better if we could completely