Skip to content

Commit

Permalink
Resolved issue with agent origination continuing after queue timeout (F…
Browse files Browse the repository at this point in the history
…ixed #31)
  • Loading branch information
danielfinke authored and jamesaimonetti committed May 18, 2015
1 parent 1a48086 commit 68fecd1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
10 changes: 9 additions & 1 deletion applications/acdc/src/acdc_queue_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,17 @@ connecting({'timeout', ConnRef, ?CONNECTION_TIMEOUT_MESSAGE}, #state{queue_proc=
,account_id=AccountId
,queue_id=QueueId
,member_call=Call
,member_call_winner=Winner
}=State) ->
lager:debug("connection timeout occurred, bounce the caller out of the queue"),
acdc_queue_listener:timeout_member_call(Srv),

case Winner of
undefined ->
acdc_queue_listener:timeout_member_call(Srv);
_ ->
acdc_queue_listener:timeout_member_call(Srv, Winner)
end,

acdc_stats:call_abandoned(AccountId, QueueId, whapps_call:call_id(Call), ?ABANDON_TIMEOUT),

webseq:evt(?WSD_ID, self(), whapps_call:call_id(Call), <<"member call finish - timeout">>),
Expand Down
18 changes: 15 additions & 3 deletions applications/acdc/src/acdc_queue_listener.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
,member_connect_req/4
,member_connect_re_req/1
,member_connect_win/3
,timeout_member_call/1
,timeout_member_call/1, timeout_member_call/2
,timeout_agent/2
,exit_member_call/1
,finish_member_call/1, finish_member_call/2
Expand Down Expand Up @@ -139,7 +139,11 @@ timeout_agent(Srv, RespJObj) ->

-spec timeout_member_call(pid()) -> 'ok'.
timeout_member_call(Srv) ->
gen_listener:cast(Srv, {'timeout_member_call'}).
timeout_member_call(Srv, undefined).
-spec timeout_member_call(pid(), wh_json:object()) -> ok.
timeout_member_call(Srv, JObj) ->
gen_listener:cast(Srv, {timeout_member_call, JObj}).

exit_member_call(Srv) ->
gen_listener:cast(Srv, {'exit_member_call'}).

Expand Down Expand Up @@ -339,7 +343,7 @@ handle_cast({'timeout_agent', RespJObj}, #state{queue_id=QueueId
lager:debug("timing out winning agent"),
send_agent_timeout(RespJObj, Call, QueueId),
{'noreply', State#state{agent_id='undefined'}, 'hibernate'};
handle_cast({'timeout_member_call'}, #state{delivery=Delivery
handle_cast({'timeout_member_call', JObj}, #state{delivery=Delivery
,call=Call
,shared_pid=Pid
,member_call_queue=Q
Expand All @@ -353,6 +357,14 @@ handle_cast({'timeout_member_call'}, #state{delivery=Delivery
acdc_util:unbind_from_call_events(Call),
lager:debug("unbound from call events for ~s", [whapps_call:call_id(Call)]),

case AgentId of
undefined ->
ok;
_ ->
lager:debug("timing out winning agent because they should not be able to pick up after the queue timeout"),
send_agent_timeout(JObj, Call, QueueId)
end,

acdc_queue_shared:ack(Pid, Delivery),
send_member_call_failure(Q, AcctId, QueueId, whapps_call:call_id(Call), MyId, AgentId),

Expand Down

0 comments on commit 68fecd1

Please sign in to comment.