diff --git a/apps/ff_transfer/src/ff_transfer_machine.erl b/apps/ff_transfer/src/ff_transfer_machine.erl index 88cc9e9..e53a43d 100644 --- a/apps/ff_transfer/src/ff_transfer_machine.erl +++ b/apps/ff_transfer/src/ff_transfer_machine.erl @@ -128,6 +128,8 @@ transfer(St) -> %% Machinery +-define(MAX_SESSION_POLL_TIMEOUT, 4 * 60 * 60). + -type machine() :: ff_machine:machine(event(_)). -type result() :: ff_machine:result(event(_)). -type handler_opts() :: machinery:handler_opts(_). @@ -181,9 +183,12 @@ set_action(undefined, _St) -> undefined; set_action(poll, St) -> Now = machinery_time:now(), - Timeout = erlang:max(1, machinery_time:interval(Now, ff_machine:updated(St)) div 1000), - {set_timer, {timeout, Timeout}}. + {set_timer, {timeout, compute_poll_timeout(Now, St)}}. +compute_poll_timeout(Now, St) -> + MaxTimeout = genlib_app:env(ff_transfer, max_session_poll_timeout, ?MAX_SESSION_POLL_TIMEOUT), + Timeout0 = machinery_time:interval(Now, ff_machine:updated(St)) div 1000, + erlang:min(MaxTimeout, erlang:max(1, Timeout0)). %% Handler convertors diff --git a/config/sys.config b/config/sys.config index 63df5e9..21704fc 100644 --- a/config/sys.config +++ b/config/sys.config @@ -99,7 +99,8 @@ } } } - }} + }}, + {max_session_poll_timeout, 14400} %% 4h ]}, %% wapi