Commits

Kevin Smith  committed c14248a

Adding support for inifinite timeouts

  • Participants
  • Parent commits 28776e7

Comments (0)

Files changed (1)

File apps/luke/src/luke_flow.erl

     gen_fsm:start_link(?MODULE, [Client, FlowId, FlowDesc, Timeout], []).
 
 init([Client, FlowId, FlowDesc, Timeout0]) ->
-    Timeout = erlang:trunc(Timeout0 * 1.1),
+    Timeout = case Timeout0 of
+                  infinity ->
+                      Timeout0;
+                  _ ->
+                      erlang:trunc(Timeout0 * 1.1)
+              end,
     case start_phases(FlowDesc, Timeout) of
         {ok, FSMs} ->
             {ok, executing, #state{fsms=FSMs, flow_id=FlowId, timeout=Timeout, client=Client}, Timeout};
 
 %% Internal functions
 start_phases(FlowDesc, Timeout) ->
-    PerPhaseTimeout = erlang:trunc(Timeout / length(FlowDesc)),
+    PerPhaseTimeout = case Timeout of
+                          infinity ->
+                              Timeout;
+                          _ ->
+                              erlang:trunc(Timeout / length(FlowDesc))
+                      end,
     start_phases(lists:reverse(FlowDesc), PerPhaseTimeout, []).
 
 start_phases([], _Timeout, Accum) ->