Fix. problem when same session can release task multiple times.

It can be when originate has group dial-string. So it call `api_hangup_hook`
for each channel.
Now we release task in `retry.lua` only if originate success and this is same channel
which execute `exec.lua`.
If originate fail we release task `next.lua`
This commit is contained in:
Alexey Melnichuk
2015-11-26 17:23:33 +03:00
parent 35752445c3
commit ac44787e36
5 changed files with 47 additions and 15 deletions

View File

@@ -10,7 +10,7 @@
local Tasks = require "fax_queue.tasks"
local fax_task_uuid = env:getHeader('fax_task_uuid')
local task = Tasks.select_task(fax_task_uuid)
local task = Tasks.select_task(fax_task_uuid)
if not task then
log.warningf("Can not find fax task: %q", tostring(fax_task_uuid))
return
@@ -25,6 +25,7 @@
-- Channel/FusionPBX variables
local uuid = env:getHeader("uuid")
local fax_queue_task_session = env:getHeader('fax_queue_task_session')
local domain_uuid = env:getHeader("domain_uuid") or task.domain_uuid
local domain_name = env:getHeader("domain_name") or task.domain_name
local origination_caller_id_name = env:getHeader("origination_caller_id_name") or '000000000000000'
@@ -338,9 +339,15 @@
end
end
Tasks.wait_task(task, answered, hangup_cause_q850)
if task.status ~= 0 then
Tasks.remove_task(task)
-- if task use group call then retry.lua will be called multiple times
-- here we check eathre that channel which execute `exec.lua`
-- Note that if there no one execute `exec.lua` we do not need call this
-- becase it should deal in `next.lua`
if fax_queue_task_session == uuid then
Tasks.wait_task(task, answered, hangup_cause_q850)
if task.status ~= 0 then
Tasks.remove_task(task)
end
end
end