Commit ca7109b3 authored by Julian Bouzas's avatar Julian Bouzas Committed by George Kiagiadakis
Browse files

policy-node: add check to not relink more than 5 times if link with peer fails

parent d47df77c
Pipeline #442605 passed with stages
in 2 minutes and 7 seconds
...@@ -24,6 +24,15 @@ function createLink (si, si_target, passthrough, exclusive) ...@@ -24,6 +24,15 @@ function createLink (si, si_target, passthrough, exclusive)
local si_props = si.properties local si_props = si.properties
local target_props = si_target.properties local target_props = si_target.properties
-- break rescan if tried more than 5 times with same target
if si_flags[si.id].failed_peer_id ~= nil and
si_flags[si.id].failed_peer_id == si_target.id and
si_flags[si.id].failed_count ~= nil and
si_flags[si.id].failed_count > 5 then
Log.warning (si, "tried to link on last rescan, not retrying")
return
end
if si_props["item.node.direction"] == "output" then if si_props["item.node.direction"] == "output" then
-- playback -- playback
out_item = si out_item = si
...@@ -61,6 +70,12 @@ function createLink (si, si_target, passthrough, exclusive) ...@@ -61,6 +70,12 @@ function createLink (si, si_target, passthrough, exclusive)
-- register -- register
si_flags[si.id].peer_id = si_target.id si_flags[si.id].peer_id = si_target.id
si_flags[si.id].failed_peer_id = si_target.id
if si_flags[si.id].failed_count ~= nil then
si_flags[si.id].failed_count = si_flags[si.id].failed_count + 1
else
si_flags[si.id].failed_count = 1
end
si_link:register () si_link:register ()
-- activate -- activate
...@@ -70,6 +85,8 @@ function createLink (si, si_target, passthrough, exclusive) ...@@ -70,6 +85,8 @@ function createLink (si, si_target, passthrough, exclusive)
si_flags[si.id].peer_id = nil si_flags[si.id].peer_id = nil
l:remove () l:remove ()
else else
si_flags[si.id].failed_peer_id = nil
si_flags[si.id].failed_count = 0
Log.info (l, "activated si-standard-link") Log.info (l, "activated si-standard-link")
end end
end) end)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment