1
0
mirror of https://github.com/20kdc/OC-KittenOS.git synced 2024-11-23 10:58:06 +11:00

Fix service autostart hang if a service was already active

This commit is contained in:
20kdc 2018-04-25 19:52:23 +01:00
parent 0b918437d0
commit bed9f55d70
2 changed files with 25 additions and 29 deletions

View File

@ -268,35 +268,33 @@ rootAccess.securityPolicy = function (pid, proc, perm, req)
secPolicyStage2(pid, proc, perm, req) secPolicyStage2(pid, proc, perm, req)
end end
-- Do we need to start it? -- Do we need to start it?
if perm:sub(1, 6) == "x.svc." then if perm:sub(1, 6) == "x.svc." and not neo.usAccessExists(perm) then
if not neo.usAccessExists(perm) then local appAct = perm:sub(7)
local appAct = perm:sub(7) local paP = appAct:match(endAcPattern)
local paP = appAct:match(endAcPattern) if paP then
if paP then appAct = appAct:sub(1, #appAct - #paP)
appAct = appAct:sub(1, #appAct - #paP) end
end -- Prepare for success
-- Prepare for success onReg[perm] = onReg[perm] or {}
onReg[perm] = onReg[perm] or {} table.insert(onReg[perm], function ()
table.insert(onReg[perm], function () finish()
finish() end)
end) pcall(neo.executeAsync, "svc-" .. appAct)
pcall(neo.executeAsync, "svc-" .. appAct) -- Fallback "quit now"
-- Fallback "quit now" local time = os.uptime() + 30
local time = os.uptime() + 30 neo.scheduleTimer(time)
neo.scheduleTimer(time) local f
local f function f()
function f() if finish then
if finish then if os.uptime() >= time then
if os.uptime() >= time then finish()
finish() else
else table.insert(todo, f)
table.insert(todo, f)
end
end end
end end
table.insert(todo, f)
return
end end
table.insert(todo, f)
return
else else
finish() finish()
end end

View File

@ -335,9 +335,7 @@ baseProcNeo = {
listLibs = lister("libs/"), listLibs = lister("libs/"),
usAccessExists = function (accessName) usAccessExists = function (accessName)
ensureType(accessName, "string") ensureType(accessName, "string")
if accesses[accessName] then return not not accesses[accessName]
return true
end
end, end,
totalIdleTime = function () return idleTime end, totalIdleTime = function () return idleTime end,
ensurePath = ensurePath, ensurePath = ensurePath,