mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-12-13 14:43:09 +00:00
bail when calling spawn{} on nonactive/blocked events
This commit is contained in:
parent
5a0117a9d7
commit
7188748d64
23
lsyncd.lua
23
lsyncd.lua
@ -2934,14 +2934,29 @@ function spawn(agent, binary, ...)
|
||||
if type(binary) ~= "string" then
|
||||
error("calling spawn(agent, binary, ...), binary is not a string", 2)
|
||||
end
|
||||
local dol = InletFactory.getDelayOrList(agent)
|
||||
if not dol then
|
||||
error("spawning with an unknown agent", 2)
|
||||
end
|
||||
|
||||
-- checks if spawn is called on already active event
|
||||
if dol.status then
|
||||
if dol.status ~= "wait" then
|
||||
error("Spawn() called on an non-waiting event", 2)
|
||||
end
|
||||
else -- is a list
|
||||
for _, d in ipairs(dol) do
|
||||
if d.status ~= "wait" and d.status ~= "block" then
|
||||
error("Spawn() called on an non-waiting event list", 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local pid = lsyncd.exec(binary, ...)
|
||||
|
||||
if pid and pid > 0 then
|
||||
local sync = InletFactory.getSync(agent)
|
||||
-- delay or list
|
||||
local dol = InletFactory.getDelayOrList(agent)
|
||||
if not dol then
|
||||
error("spawning with an unknown agent", 2)
|
||||
end
|
||||
if dol.status then
|
||||
-- is a delay
|
||||
dol.status = "active"
|
||||
|
Loading…
Reference in New Issue
Block a user