policy-node/create-item: fix handling of linkables pending activation
Policies need to know if there are session items that are pending activation. Linkables are not activated in the same order as nodes appear, which causes problems for e.g. resolving target nodes, if some of the linkables are pending. Register linkables in create-items before they are activated. When activation completes, remove those that did not activate successfully. Policies can filter out inactive items by tracking active-features flags. If there are existing linkables that are not ready, suspend policy-node processing, and continue it only after all linkables are ready.
This commit is contained in:
@@ -58,24 +58,36 @@ end
|
||||
|
||||
function addItem (node, item_type)
|
||||
local id = node["bound-id"]
|
||||
local item
|
||||
|
||||
-- create item
|
||||
items[id] = SessionItem ( item_type )
|
||||
item = SessionItem ( item_type )
|
||||
items[id] = item
|
||||
|
||||
-- configure item
|
||||
if not items[id]:configure(configProperties(node)) then
|
||||
Log.warning(items[id], "failed to configure item for node " .. tostring(id))
|
||||
if not item:configure(configProperties(node)) then
|
||||
Log.warning(item, "failed to configure item for node " .. tostring(id))
|
||||
return
|
||||
end
|
||||
|
||||
item:register ()
|
||||
|
||||
-- activate item
|
||||
items[id]:activate (Features.ALL, function (item, e)
|
||||
if e then
|
||||
Log.message(item, "failed to activate item: " .. tostring(e));
|
||||
if item then
|
||||
item:remove ()
|
||||
end
|
||||
else
|
||||
Log.info(item, "activated item for node " .. tostring(id))
|
||||
item:register ()
|
||||
end
|
||||
|
||||
-- Trigger object managers to update status
|
||||
item:remove ()
|
||||
if item["active-features"] ~= 0 then
|
||||
item:register ()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user