Skip to content

Commit

Permalink
Claim name in central lwaftr ptree manager function
Browse files Browse the repository at this point in the history
Otherwise, we would never claim the name when starting with an empty
config.
  • Loading branch information
wingo committed Apr 23, 2018
1 parent 51ead80 commit a5bed82
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/program/lwaftr/setup.lua
Expand Up @@ -62,24 +62,6 @@ function lwaftr_app(c, conf)
local function append(t, elem) table.insert(t, elem) end
local function prepend(t, elem) table.insert(t, 1, elem) end

-- Claim the name if one is defined.
local function switch_names(config)
local currentname = engine.program_name
local name = config.softwire_config.name
-- Don't do anything if the name isn't set.
if name == nil then
return
end

local success, err = pcall(engine.claim_name, name)
if success == false then
-- Restore the previous name.
config.softwire_config.name = currentname
assert(success, err)
end
end
switch_names(conf)

local device, id, queue = lwutil.parse_instance(conf)

-- Global interfaces
Expand Down Expand Up @@ -587,7 +569,24 @@ local function compute_worker_configs(conf)
end

function ptree_manager(f, conf, manager_opts)
-- Claim the name if one is defined.
local function switch_names(config)
local currentname = engine.program_name
local name = config.softwire_config.name
-- Don't do anything if the name isn't set.
if name == nil then
return
end
local success, err = pcall(engine.claim_name, name)
if success == false then
-- Restore the previous name.
config.softwire_config.name = currentname
assert(success, err)
end
end

local function setup_fn(conf)
switch_names(conf)
local worker_app_graphs = {}
for worker_id, worker_config in pairs(compute_worker_configs(conf)) do
local app_graph = config.new()
Expand Down

0 comments on commit a5bed82

Please sign in to comment.