diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2019-07-23 00:15:40 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2019-07-23 00:15:40 +0200 |
commit | 8ac4a5f79290f47e9cfff454dc7d5f6cd2225bc7 (patch) | |
tree | 56038e363899c6b460e77265a1e286c62651b216 /src/mod_stream_mgmt.erl | |
parent | Fix wrong virtual host in mod_pubsub:send_stanza (#2930) (diff) |
mod_stream_mgmt: Allow flexible timeout format
Adjust mod_stream_mgmt and the related code in mod_push_keepalive to
support the flexible timeout format.
Diffstat (limited to 'src/mod_stream_mgmt.erl')
-rw-r--r-- | src/mod_stream_mgmt.erl | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/mod_stream_mgmt.erl b/src/mod_stream_mgmt.erl index 030a36b80..f03c8c735 100644 --- a/src/mod_stream_mgmt.erl +++ b/src/mod_stream_mgmt.erl @@ -445,7 +445,7 @@ transition_to_pending(#{mgmt_state := active, jid := JID, lserver := LServer, mgmt_timeout := Timeout} = State) -> State1 = cancel_ack_timer(State), ?INFO_MSG("Waiting for resumption of stream for ~s", [jid:encode(JID)]), - TRef = erlang:start_timer(timer:seconds(Timeout), self(), pending_timeout), + TRef = erlang:start_timer(Timeout, self(), pending_timeout), State2 = State1#{mgmt_state => pending, mgmt_pending_timer => TRef}, ejabberd_hooks:run_fold(c2s_session_pending, LServer, State2, []); transition_to_pending(State) -> @@ -699,8 +699,7 @@ send(#{mod := Mod} = State, Pkt) -> -spec restart_pending_timer(state(), non_neg_integer()) -> state(). restart_pending_timer(#{mgmt_pending_timer := TRef} = State, NewTimeout) -> misc:cancel_timer(TRef), - NewTRef = erlang:start_timer(timer:seconds(NewTimeout), self(), - pending_timeout), + NewTRef = erlang:start_timer(NewTimeout, self(), pending_timeout), State#{mgmt_pending_timer => NewTRef}; restart_pending_timer(State, _NewTimeout) -> State. @@ -805,9 +804,13 @@ get_queue_type(Host) -> mod_opt_type(max_ack_queue) -> econf:pos_int(infinity); mod_opt_type(resume_timeout) -> - econf:non_neg_int(); + econf:either( + econf:int(0, 0), + econf:timeout(second)); mod_opt_type(max_resume_timeout) -> - econf:non_neg_int(); + econf:either( + econf:int(0, 0), + econf:timeout(second)); mod_opt_type(ack_timeout) -> econf:timeout(second, infinity); mod_opt_type(resend_on_timeout) -> |