Skip to content

Commit

Permalink
HELP-44667: for error replies wait for authz when enabled so the chan…
Browse files Browse the repository at this point in the history
…nel_destroy is not missed (2600hz#5849)

fixed unused vars
  • Loading branch information
k-anderson authored and jamesaimonetti committed Jun 18, 2019
1 parent f8cd56b commit f475364
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion applications/ecallmgr/src/fetch/ecallmgr_fs_fetch_dialplan.erl
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,34 @@ authorize_call_fun(Parent, Ref, Node, CallId, JObj) ->
maybe_wait_for_authz(#{authz_worker := _AuthzWorker, reply := #{payload := Reply}}=Map) ->
case kz_json:get_value(<<"Method">>, Reply) =/= <<"error">> of
'true' -> wait_for_authz(Map);
'false' -> send_reply(Map)
'false' -> wait_and_ignore_authz(Map)
end;
maybe_wait_for_authz(#{}=Map) ->
send_reply(Map).

-spec wait_and_ignore_authz(dialplan_context()) -> {'ok', dialplan_context()}.
wait_and_ignore_authz(#{authz_worker := {Pid, Ref}
,authz_timeout := Timeout
}=Map) ->
%% If we don't wait for an authz worker and just send an error reply
%% as soon as the route_resp comes in then FreeSWITCH will terminate
%% the call and Jonny5 will still be processing the authz_req.
%% If Jonny5 authorizes the now dead call then it will add it to
%% the j5_channels but FreeSWITCH will have already destroyed
%% it and the CHANNEL_DESTROY will have already been sent
%% to j5_channels so the authorization gets stuck.
lager:info("waiting for authz reply from worker ~p", [Pid]),
receive
{'authorize_reply', Ref, _} ->
lager:debug("got authz reply, but sending error response so ignoring"),
send_reply(Map)
after Timeout ->
lager:warning("timeout waiting for authz reply from worker ~p but sending error so ignoring"
,[Pid]
),
send_reply(Map)
end.

-spec wait_for_authz(dialplan_context()) -> {'ok', dialplan_context()}.
wait_for_authz(#{authz_worker := {Pid, Ref}
,authz_timeout := Timeout
Expand Down

0 comments on commit f475364

Please sign in to comment.