iwalk -> ipairs

This commit is contained in:
Axel Kittenberger 2018-05-14 08:56:42 +02:00
parent d72667e1ae
commit 14d41116c0
4 changed files with 15 additions and 14 deletions

View File

@ -122,7 +122,7 @@ function mci.collectProcess
error( 'negative number of processes!' )
end
for _, s in SyncMaster.iwalk( )
for _, s in ipairs( SyncMaster )
do
if s:collect( pid, exitcode ) then return end
end
@ -452,7 +452,7 @@ function mci.initialize
}
-- translates layer 3 scripts
for _, s in SyncMaster.iwalk()
for _, s in ipairs( SyncMaster )
do
-- checks if any user functions is a layer 3 string.
local config = s.config
@ -469,7 +469,7 @@ function mci.initialize
end
-- runs through the Syncs created by users
for _, s in SyncMaster.iwalk( )
for _, s in ipairs( SyncMaster )
do
if s.config.monitor == 'inotify'
then
@ -532,7 +532,7 @@ function mci.getAlarm
if not uSettings.maxProcesses
or processCount < uSettings.maxProcesses
then
for _, s in SyncMaster.iwalk( )
for _, s in ipairs( SyncMaster )
do
checkAlarm( s:getAlarm( ) )
end

View File

@ -91,7 +91,7 @@ local function write
f:write( 'Lsyncd status report at ', os.date( ), '\n\n' )
for i, s in SyncMaster.iwalk( )
for i, s in ipairs( SyncMaster )
do
s:statusReport( f )

View File

@ -36,6 +36,15 @@ mt.__len = function
end
--
-- Walks the syncs.
--
mt.__ipairs = function
( )
return ipairs( syncList )
end
--
-- The round robin counter. In case of global limited maxProcesses
-- gives every sync equal chances to spawn the next process.
@ -284,13 +293,6 @@ local function add
return s
end
--
-- Allows a for-loop to walk through all syncs.
--
local function iwalk
( )
return ipairs( syncList )
end
--
-- Tests if any sync is interested in a path.
@ -319,7 +321,6 @@ SyncMaster =
get = get, -- FIXME forward through metatable
getRound = getRound,
concerns = concerns,
iwalk = iwalk, -- FIXME ipairs metatable
nextRound = nextRound
}

View File

@ -261,7 +261,7 @@ user.syncs =
__ipairs =
function
( )
return SyncMaster.iwalk( )
return ipairs( SyncMaster )
end
}