Skip to content

Commit

Permalink
fix branched callflow not being properly killed, prevent cf_pivot fro…
Browse files Browse the repository at this point in the history
…m waiting forever (2600hz#5222)
  • Loading branch information
mark2600 authored and jamesaimonetti committed Oct 16, 2018
1 parent cc35d4e commit d5932c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
20 changes: 19 additions & 1 deletion applications/callflow/src/cf_exe.erl
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,12 @@ handle_info({'DOWN', Ref, 'process', Pid, 'normal'}, #state{cf_module_pid={Pid,
erlang:demonitor(Ref, ['flush']),
lager:debug("cf module ~s down normally", [kapps_call:kvs_fetch('cf_last_action', Call)]),
{'noreply', State#state{cf_module_pid='undefined'}};
handle_info({'DOWN', Ref, 'process', Pid, 'killed'}, #state{cf_module_pid={Pid, Ref}
,call=Call
}=State) ->
erlang:demonitor(Ref, ['flush']),
lager:debug("cf module ~s down normally", [kapps_call:kvs_fetch('cf_last_action', Call)]),
{'noreply', State#state{cf_module_pid='undefined'}};
handle_info({'DOWN', Ref, 'process', Pid, _Reason}, #state{cf_module_pid={Pid, Ref}
,call=Call
}=State) ->
Expand All @@ -556,6 +562,12 @@ handle_info({'EXIT', Pid, 'normal'}, #state{cf_module_pid={Pid, Ref}
erlang:demonitor(Ref, ['flush']),
lager:debug("cf module ~s down normally", [kapps_call:kvs_fetch('cf_last_action', Call)]),
{'noreply', State#state{cf_module_pid='undefined'}};
handle_info({'EXIT', Pid, 'killed'}, #state{cf_module_pid={Pid, Ref}
,call=Call
}=State) ->
erlang:demonitor(Ref, ['flush']),
lager:debug("cf module ~s killed normally", [kapps_call:kvs_fetch('cf_last_action', Call)]),
{'noreply', State#state{cf_module_pid='undefined'}};
handle_info({'EXIT', Pid, _Reason}, #state{cf_module_pid={Pid, Ref}
,call=Call
}=State) ->
Expand All @@ -570,6 +582,12 @@ handle_info({'EXIT', Pid, 'normal'}, #state{cf_module_old_pid={Pid, Ref}
erlang:demonitor(Ref, ['flush']),
lager:debug("cf module ~s down normally", [kapps_call:kvs_fetch('cf_old_action', Call)]),
{'noreply', State#state{cf_module_old_pid='undefined'}};
handle_info({'EXIT', Pid, 'killed'}, #state{cf_module_old_pid={Pid, Ref}
,call=Call
}=State) ->
erlang:demonitor(Ref, ['flush']),
lager:debug("cf module ~s killed normally", [kapps_call:kvs_fetch('cf_old_action', Call)]),
{'noreply', State#state{cf_module_old_pid='undefined'}};
handle_info({'EXIT', Pid, _Reason}, #state{cf_module_old_pid={Pid, Ref}
,call=Call
}=State) ->
Expand Down Expand Up @@ -906,7 +924,7 @@ handle_channel_pivoted(Self, PidRef, JObj, Call) ->

-spec maybe_stop_action(kz_term:api_pid_ref()) -> 'ok'.
maybe_stop_action({Pid, _Ref}) ->
exit(Pid, 'normal');
exit(Pid, 'kill');
maybe_stop_action('undefined') -> 'ok'.

-spec stop_bad_destination(kapps_call:call()) -> 'ok'.
Expand Down
5 changes: 3 additions & 2 deletions applications/callflow/src/module/cf_pivot.erl
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ wait_for_pivot(Data, Call) ->
{<<"pivot">>,<<"failed">>} ->
lager:warning("pivot failed failing back to next callflow action"),
cf_exe:continue(Call);
_ ->
_Other ->
wait_for_pivot(Data, Call)
end;
{'error', 'timeout'} ->
wait_for_pivot(Data, Call)
lager:error("timeout waiting for pivot response, continuing"),
cf_exe:continue(Call)
end.

0 comments on commit d5932c3

Please sign in to comment.