aboutsummaryrefslogtreecommitdiff
path: root/src/mod_stream_mgmt.erl
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2018-04-17 00:27:07 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2018-04-17 00:27:07 +0200
commit332567693c3d3eb36c70fdbd591296b8caeaa999 (patch)
tree462c4ed8cfae51ccb1c654a298128de04401ce46 /src/mod_stream_mgmt.erl
parentmod_push: Optionally include message sender/body (diff)
mod_push_keepalive: Reset timeout on messages only
Some mobile apps might only be notified on actual chat messages with a body, so don't let mod_push_keepalive reset the stream management timeout on other types of traffic.
Diffstat (limited to 'src/mod_stream_mgmt.erl')
-rw-r--r--src/mod_stream_mgmt.erl21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/mod_stream_mgmt.erl b/src/mod_stream_mgmt.erl
index a8aeaaef0..5ebd16cb0 100644
--- a/src/mod_stream_mgmt.erl
+++ b/src/mod_stream_mgmt.erl
@@ -33,8 +33,8 @@
c2s_unbinded_packet/2, c2s_closed/2, c2s_terminated/2,
c2s_handle_send/3, c2s_handle_info/2, c2s_handle_call/3,
c2s_handle_recv/3]).
-%% adjust pending session timeout
--export([get_resume_timeout/1, set_resume_timeout/2]).
+%% adjust pending session timeout / access queue
+-export([get_resume_timeout/1, set_resume_timeout/2, queue_find/2]).
-include("ejabberd.hrl").
-include("xmpp.hrl").
@@ -304,7 +304,7 @@ c2s_terminated(State, _Reason) ->
State.
%%%===================================================================
-%%% Adjust pending session timeout
+%%% Adjust pending session timeout / access queue
%%%===================================================================
-spec get_resume_timeout(state()) -> non_neg_integer().
get_resume_timeout(#{mgmt_timeout := Timeout}) ->
@@ -317,6 +317,21 @@ set_resume_timeout(State, Timeout) ->
State1 = restart_pending_timer(State, Timeout),
State1#{mgmt_timeout => Timeout}.
+-spec queue_find(fun((stanza()) -> boolean()), p1_queue:queue())
+ -> stanza() | none.
+queue_find(Pred, Queue) ->
+ case p1_queue:out(Queue) of
+ {{value, {_, _, Pkt}}, Queue1} ->
+ case Pred(Pkt) of
+ true ->
+ Pkt;
+ false ->
+ queue_find(Pred, Queue1)
+ end;
+ {empty, _Queue1} ->
+ none
+ end.
+
%%%===================================================================
%%% Internal functions
%%%===================================================================