Correctly report resume timeout

This commit is contained in:
Evgeny Khramtsov 2019-07-30 12:50:31 +03:00
parent 8a2b2668cf
commit 59adfcb8e0
2 changed files with 6 additions and 5 deletions

View File

@ -201,13 +201,13 @@ maybe_adjust_resume_timeout(#{push_resume_timeout := undefined} = State) ->
State;
maybe_adjust_resume_timeout(#{push_resume_timeout := Timeout} = State) ->
OrigTimeout = mod_stream_mgmt:get_resume_timeout(State),
?DEBUG("Adjusting resume timeout to ~B seconds", [Timeout]),
?DEBUG("Adjusting resume timeout to ~B seconds", [Timeout div 1000]),
State1 = mod_stream_mgmt:set_resume_timeout(State, Timeout),
State1#{push_resume_timeout_orig => OrigTimeout}.
-spec maybe_restore_resume_timeout(c2s_state()) -> c2s_state().
maybe_restore_resume_timeout(#{push_resume_timeout_orig := Timeout} = State) ->
?DEBUG("Restoring resume timeout to ~B seconds", [Timeout]),
?DEBUG("Restoring resume timeout to ~B seconds", [Timeout div 1000]),
State1 = mod_stream_mgmt:set_resume_timeout(State, Timeout),
maps:remove(push_resume_timeout_orig, State1);
maybe_restore_resume_timeout(State) ->
@ -218,7 +218,7 @@ maybe_start_wakeup_timer(#{push_wake_on_timeout := true,
push_resume_timeout := ResumeTimeout} = State)
when is_integer(ResumeTimeout), ResumeTimeout > ?PUSH_BEFORE_TIMEOUT_PERIOD ->
WakeTimeout = ResumeTimeout - ?PUSH_BEFORE_TIMEOUT_PERIOD,
?DEBUG("Scheduling wake-up timer to fire in ~B seconds", [WakeTimeout]),
?DEBUG("Scheduling wake-up timer to fire in ~B seconds", [WakeTimeout div 1000]),
erlang:start_timer(WakeTimeout, self(), push_keepalive),
State;
maybe_start_wakeup_timer(State) ->

View File

@ -381,7 +381,7 @@ handle_enable(#{mgmt_timeout := DefaultTimeout,
#sm_enabled{xmlns = Xmlns,
id = make_resume_id(State),
resume = true,
max = Timeout};
max = Timeout div 1000};
true ->
?DEBUG("Stream management without resumption enabled for ~s",
[jid:encode(JID)]),
@ -444,7 +444,8 @@ transition_to_pending(#{mgmt_state := active, mod := Mod,
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)]),
?INFO_MSG("Waiting ~B seconds for resumption of stream for ~s",
[Timeout div 1000, jid:encode(JID)]),
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, []);