From 59adfcb8e0a85bb053f70f721160ae0d7199683b Mon Sep 17 00:00:00 2001 From: Evgeny Khramtsov Date: Tue, 30 Jul 2019 12:50:31 +0300 Subject: [PATCH] Correctly report resume timeout --- src/mod_push_keepalive.erl | 6 +++--- src/mod_stream_mgmt.erl | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mod_push_keepalive.erl b/src/mod_push_keepalive.erl index 3f55eaa92..c4e8f03d2 100644 --- a/src/mod_push_keepalive.erl +++ b/src/mod_push_keepalive.erl @@ -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) -> diff --git a/src/mod_stream_mgmt.erl b/src/mod_stream_mgmt.erl index 829c07e1a..e086b29cc 100644 --- a/src/mod_stream_mgmt.erl +++ b/src/mod_stream_mgmt.erl @@ -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, []);