From bed9f55d70eeea00f999dd277e2d521434c3a5ea Mon Sep 17 00:00:00 2001 From: 20kdc Date: Wed, 25 Apr 2018 19:52:23 +0100 Subject: [PATCH] Fix service autostart hang if a service was already active --- code/apps/sys-icecap.lua | 50 +++++++++++++++++++--------------------- code/init.lua | 4 +--- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/code/apps/sys-icecap.lua b/code/apps/sys-icecap.lua index 91a0ab4..1cddf43 100644 --- a/code/apps/sys-icecap.lua +++ b/code/apps/sys-icecap.lua @@ -268,35 +268,33 @@ rootAccess.securityPolicy = function (pid, proc, perm, req) secPolicyStage2(pid, proc, perm, req) end -- Do we need to start it? - if perm:sub(1, 6) == "x.svc." then - if not neo.usAccessExists(perm) then - local appAct = perm:sub(7) - local paP = appAct:match(endAcPattern) - if paP then - appAct = appAct:sub(1, #appAct - #paP) - end - -- Prepare for success - onReg[perm] = onReg[perm] or {} - table.insert(onReg[perm], function () - finish() - end) - pcall(neo.executeAsync, "svc-" .. appAct) - -- Fallback "quit now" - local time = os.uptime() + 30 - neo.scheduleTimer(time) - local f - function f() - if finish then - if os.uptime() >= time then - finish() - else - table.insert(todo, f) - end + if perm:sub(1, 6) == "x.svc." and not neo.usAccessExists(perm) then + local appAct = perm:sub(7) + local paP = appAct:match(endAcPattern) + if paP then + appAct = appAct:sub(1, #appAct - #paP) + end + -- Prepare for success + onReg[perm] = onReg[perm] or {} + table.insert(onReg[perm], function () + finish() + end) + pcall(neo.executeAsync, "svc-" .. appAct) + -- Fallback "quit now" + local time = os.uptime() + 30 + neo.scheduleTimer(time) + local f + function f() + if finish then + if os.uptime() >= time then + finish() + else + table.insert(todo, f) end end - table.insert(todo, f) - return end + table.insert(todo, f) + return else finish() end diff --git a/code/init.lua b/code/init.lua index 7fb1ee4..1f292f5 100644 --- a/code/init.lua +++ b/code/init.lua @@ -335,9 +335,7 @@ baseProcNeo = { listLibs = lister("libs/"), usAccessExists = function (accessName) ensureType(accessName, "string") - if accesses[accessName] then - return true - end + return not not accesses[accessName] end, totalIdleTime = function () return idleTime end, ensurePath = ensurePath,