mirror of https://github.com/octoleo/lsyncd.git
Fixed Delay changes potentially not reflect on Event layer. Fixed test exitcode
This commit is contained in:
parent
9e647f8113
commit
837a3cd927
|
@ -30,6 +30,9 @@
|
||||||
are found.
|
are found.
|
||||||
fix: Shell injection hole close for default.direct on mv commands. (Marcin Szewczyk)
|
fix: Shell injection hole close for default.direct on mv commands. (Marcin Szewczyk)
|
||||||
fix: Crash of default-direct when source doesn't exit (Michael Ploujnikov)
|
fix: Crash of default-direct when source doesn't exit (Michael Ploujnikov)
|
||||||
|
fix: fixed faulty event replacement,
|
||||||
|
a race condition noticed by extensive default.rsyncssh testing
|
||||||
|
changed Delays were not reflected in Events
|
||||||
|
|
||||||
15-10-2015: 2.1.6
|
15-10-2015: 2.1.6
|
||||||
enhancement: Lsyncd now locks its pidfile
|
enhancement: Lsyncd now locks its pidfile
|
||||||
|
|
88
lsyncd.lua
88
lsyncd.lua
|
@ -433,7 +433,7 @@ Queue = ( function
|
||||||
|
|
||||||
elseif pos == nt.last
|
elseif pos == nt.last
|
||||||
then
|
then
|
||||||
local first = nt.firt
|
local first = nt.first
|
||||||
|
|
||||||
while nt[ pos ] == nil and pos >= first
|
while nt[ pos ] == nil and pos >= first
|
||||||
do
|
do
|
||||||
|
@ -454,6 +454,24 @@ Queue = ( function
|
||||||
nt.size = nt.size - 1
|
nt.size = nt.size - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Replaces a value.
|
||||||
|
--
|
||||||
|
local function replace
|
||||||
|
(
|
||||||
|
self, -- the queue
|
||||||
|
pos, -- position to replace
|
||||||
|
value -- the new entry
|
||||||
|
)
|
||||||
|
local nt = self[ k_nt ]
|
||||||
|
|
||||||
|
if nt[ pos ] == nil
|
||||||
|
then
|
||||||
|
error( 'Trying to replace an unset Queue entry.' )
|
||||||
|
end
|
||||||
|
|
||||||
|
nt[ pos ] = value
|
||||||
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Queue iterator ( stateless )
|
-- Queue iterator ( stateless )
|
||||||
|
@ -545,6 +563,7 @@ Queue = ( function
|
||||||
qpairs = qpairs,
|
qpairs = qpairs,
|
||||||
qpairsReverse = qpairsReverse,
|
qpairsReverse = qpairsReverse,
|
||||||
remove = remove,
|
remove = remove,
|
||||||
|
replace = replace,
|
||||||
size = size,
|
size = size,
|
||||||
|
|
||||||
[ k_nt ] =
|
[ k_nt ] =
|
||||||
|
@ -681,18 +700,27 @@ local Delay = ( function
|
||||||
)
|
)
|
||||||
self[ k_nt ].status = 'block'
|
self[ k_nt ].status = 'block'
|
||||||
|
|
||||||
local blocks
|
local blocks = delay[ k_nt ].blocks
|
||||||
|
|
||||||
if not self[ k_nt ].blocks
|
if not blocks
|
||||||
then
|
then
|
||||||
blocks = { }
|
blocks = { }
|
||||||
|
|
||||||
self[ k_nt ].blocks = blocks
|
delay[ k_nt ].blocks = blocks
|
||||||
else
|
|
||||||
blocks = self[ k_nt ].blocks
|
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert( blocks, delay )
|
table.insert( blocks, self )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Sets the delay status to 'active'.
|
||||||
|
--
|
||||||
|
local function setActive
|
||||||
|
(
|
||||||
|
self
|
||||||
|
)
|
||||||
|
self[ k_nt ].status = 'active'
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -712,6 +740,7 @@ local Delay = ( function
|
||||||
local delay =
|
local delay =
|
||||||
{
|
{
|
||||||
blockedBy = blockedBy,
|
blockedBy = blockedBy,
|
||||||
|
setActive = setActive,
|
||||||
[ k_nt ] =
|
[ k_nt ] =
|
||||||
{
|
{
|
||||||
etype = etype,
|
etype = etype,
|
||||||
|
@ -980,7 +1009,7 @@ local Combiner = ( function
|
||||||
|
|
||||||
d1.path2 = nil
|
d1.path2 = nil
|
||||||
|
|
||||||
return 'stack'
|
return 'toDelete,stack'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- on 'Attrib' or 'Modify' simply stack on moves
|
-- on 'Attrib' or 'Modify' simply stack on moves
|
||||||
|
@ -2196,7 +2225,11 @@ local Sync = ( function
|
||||||
' )'
|
' )'
|
||||||
)
|
)
|
||||||
|
|
||||||
-- TODO
|
--
|
||||||
|
-- In case new directories were created
|
||||||
|
-- looks through this directories and makes create events for
|
||||||
|
-- new stuff found in there.
|
||||||
|
--
|
||||||
local function recurse
|
local function recurse
|
||||||
( )
|
( )
|
||||||
if etype == 'Create' and path:byte( -1 ) == 47
|
if etype == 'Create' and path:byte( -1 ) == 47
|
||||||
|
@ -2378,15 +2411,23 @@ local Sync = ( function
|
||||||
stack( od, nd )
|
stack( od, nd )
|
||||||
|
|
||||||
nd.dpos = self.delays:push( nd )
|
nd.dpos = self.delays:push( nd )
|
||||||
|
elseif ac == 'toDelete,stack'
|
||||||
|
then
|
||||||
|
-- turns delay1 into a delete
|
||||||
|
-- and stacks delay2
|
||||||
|
local rd = Delay.new( 'Delete', self, od.alarm, od.path )
|
||||||
|
|
||||||
|
self.delays:replace( il, rd )
|
||||||
|
|
||||||
|
rd.dpos = il
|
||||||
elseif ac == 'absorb'
|
elseif ac == 'absorb'
|
||||||
then
|
then
|
||||||
-- nada
|
-- nada
|
||||||
elseif ac == 'replace'
|
elseif ac == 'replace'
|
||||||
then
|
then
|
||||||
-- TODO make this more elegant
|
self.delays:replace( il, nd )
|
||||||
od.etype = nd.etype
|
|
||||||
od.path = nd.path
|
nd.dpos = il
|
||||||
od.path2 = nd.path2
|
|
||||||
elseif ac == 'split'
|
elseif ac == 'split'
|
||||||
then
|
then
|
||||||
delay( self, 'Delete', time, path, nil )
|
delay( self, 'Delete', time, path, nil )
|
||||||
|
@ -2406,9 +2447,9 @@ local Sync = ( function
|
||||||
|
|
||||||
if nd.path2
|
if nd.path2
|
||||||
then
|
then
|
||||||
log( 'Delay','New ',nd.etype,': ',nd.path,' -> ',nd.path2 )
|
log( 'Delay', 'New ', nd.etype, ': ', nd.path, ' -> ', nd.path2 )
|
||||||
else
|
else
|
||||||
log( 'Delay','New ',nd.etype,': ',nd.path )
|
log( 'Delay', 'New ', nd.etype, ': ', nd.path )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- no block or combo
|
-- no block or combo
|
||||||
|
@ -5004,7 +5045,8 @@ function spawn(
|
||||||
then
|
then
|
||||||
-- is an event
|
-- is an event
|
||||||
|
|
||||||
if dol.status ~= 'wait' then
|
if dol.status ~= 'wait'
|
||||||
|
then
|
||||||
error('spawn() called on an non-waiting event', 2)
|
error('spawn() called on an non-waiting event', 2)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -5041,13 +5083,14 @@ function spawn(
|
||||||
if dol.status
|
if dol.status
|
||||||
then
|
then
|
||||||
-- is a delay
|
-- is a delay
|
||||||
dol.status = 'active'
|
dol:setActive( )
|
||||||
|
|
||||||
sync.processes[ pid ] = dol
|
sync.processes[ pid ] = dol
|
||||||
else
|
else
|
||||||
-- is a list
|
-- is a list
|
||||||
for _, d in ipairs( dol )
|
for _, d in ipairs( dol )
|
||||||
do
|
do
|
||||||
d.status = 'active'
|
d:setActive( )
|
||||||
end
|
end
|
||||||
|
|
||||||
sync.processes[ pid ] = dol
|
sync.processes[ pid ] = dol
|
||||||
|
@ -5058,7 +5101,8 @@ end
|
||||||
--
|
--
|
||||||
-- Spawns a child process using the default shell.
|
-- Spawns a child process using the default shell.
|
||||||
--
|
--
|
||||||
function spawnShell(
|
function spawnShell
|
||||||
|
(
|
||||||
agent, -- the delay(list) to spawn the command for
|
agent, -- the delay(list) to spawn the command for
|
||||||
command, -- the shell command
|
command, -- the shell command
|
||||||
... -- additonal arguments
|
... -- additonal arguments
|
||||||
|
@ -5077,7 +5121,8 @@ end
|
||||||
--
|
--
|
||||||
-- Observes a filedescriptor.
|
-- Observes a filedescriptor.
|
||||||
--
|
--
|
||||||
function observefd(
|
function observefd
|
||||||
|
(
|
||||||
fd, -- file descriptor
|
fd, -- file descriptor
|
||||||
ready, -- called when fd is ready to be read
|
ready, -- called when fd is ready to be read
|
||||||
writey -- called when fd is ready to be written
|
writey -- called when fd is ready to be written
|
||||||
|
@ -5093,7 +5138,8 @@ end
|
||||||
--
|
--
|
||||||
-- Stops observeing a filedescriptor.
|
-- Stops observeing a filedescriptor.
|
||||||
--
|
--
|
||||||
function nonobservefd(
|
function nonobservefd
|
||||||
|
(
|
||||||
fd -- file descriptor
|
fd -- file descriptor
|
||||||
)
|
)
|
||||||
return lsyncd.nonobserve_fd( fd )
|
return lsyncd.nonobserve_fd( fd )
|
||||||
|
|
|
@ -41,8 +41,11 @@ cwriteln( 'waiting for Lsyncd to finish its jobs.' )
|
||||||
posix.sleep( 10 )
|
posix.sleep( 10 )
|
||||||
|
|
||||||
cwriteln( 'killing the Lsyncd daemon' )
|
cwriteln( 'killing the Lsyncd daemon' )
|
||||||
|
|
||||||
posix.kill(pid)
|
posix.kill(pid)
|
||||||
local _, exitmsg, lexitcode = posix.wait(lpid)
|
|
||||||
|
local _, exitmsg, lexitcode = posix.wait( lpid )
|
||||||
|
|
||||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
||||||
|
|
||||||
_, result, code = os.execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
_, result, code = os.execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
||||||
|
@ -54,7 +57,7 @@ else
|
||||||
cwriteln( 'Signal terminating diff = ', code )
|
cwriteln( 'Signal terminating diff = ', code )
|
||||||
end
|
end
|
||||||
|
|
||||||
if exitcode ~= 0
|
if code ~= 0
|
||||||
then
|
then
|
||||||
os.exit( 1 )
|
os.exit( 1 )
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue