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

@@ -28,10 +28,6 @@ local function next_task()
local esl
local ok, err = pcall(function()
for k, v in pairs(task) do
print(string.format(" `%s` => `%s`", tostring(k), tostring(v)))
end
local mode = (task.retry_counter % #FAX_OPTIONS) + 1
local dial_string = '{' ..
task.dial_string .. "api_hangup_hook='lua fax_queue/retry.lua'," ..
@@ -42,8 +38,13 @@ local function next_task()
log.notice(originate)
esl = assert(Esl.new())
local ok, err = esl:api(originate)
log.notice(ok or err)
local ok, status, info = esl:api(originate)
if not ok then
Tasks.wait_task(task, false, info)
log.noticef('Can not originate to `%s` cause: %s: %s ', task.uri, tostring(status), tostring(info))
else
log.noticef("originate successfuly: %s", tostring(info))
end
end)
if esl then esl:close() end