mirror of
https://github.com/octoleo/lsyncd.git
synced 2025-01-07 09:04:05 +00:00
fixing masterloop
This commit is contained in:
parent
58b4f21d56
commit
306d117959
11
lsyncd.c
11
lsyncd.c
@ -905,7 +905,7 @@ l_stackdump(lua_State* L)
|
||||
|
||||
/**
|
||||
* Reads the directories entries.
|
||||
* XXX
|
||||
*
|
||||
* @param (Lua stack) absolute path to directory.
|
||||
* @return (Lua stack) a table of directory names.
|
||||
* names are keys, values are boolean
|
||||
@ -1332,6 +1332,15 @@ masterloop(lua_State *L)
|
||||
/* nothing more inotify */
|
||||
break;
|
||||
}
|
||||
if (len < 0) {
|
||||
if (errno == EAGAIN) {
|
||||
/* nothing more inotify */
|
||||
break;
|
||||
} else {
|
||||
printlogf(L, "Error", "Read fail on inotify");
|
||||
exit(-1); // ERRNO
|
||||
}
|
||||
}
|
||||
while (i < len && !hup && !term) {
|
||||
struct inotify_event *event =
|
||||
(struct inotify_event *) &readbuf[i];
|
||||
|
37
lsyncd.lua
37
lsyncd.lua
@ -1475,22 +1475,27 @@ local Inotifies = (function()
|
||||
|
||||
-- registers and adds watches for all subdirectories
|
||||
-- and/or raises create events for all entries
|
||||
if recurse or raise then
|
||||
local entries = lsyncd.readdir(path)
|
||||
for dirname, isdir in pairs(entries) do
|
||||
local pd = path .. dirname
|
||||
if isdir then
|
||||
pd = pd .. "/"
|
||||
end
|
||||
if not recurse and not raise then
|
||||
return
|
||||
end
|
||||
|
||||
local entries = lsyncd.readdir(path)
|
||||
if not entries then
|
||||
return
|
||||
end
|
||||
for dirname, isdir in pairs(entries) do
|
||||
local pd = path .. dirname
|
||||
if isdir then
|
||||
pd = pd .. "/"
|
||||
end
|
||||
|
||||
-- creates a Create event for entry.
|
||||
if raiseSync then
|
||||
raiseSync:delay("Create", raiseTime, pd, nil)
|
||||
end
|
||||
-- adds syncs for subdirs
|
||||
if isdir and recurse then
|
||||
addWatch(pd, true, raiseSync, raiseTime)
|
||||
end
|
||||
-- creates a Create event for entry.
|
||||
if raiseSync then
|
||||
raiseSync:delay("Create", raiseTime, pd, nil)
|
||||
end
|
||||
-- adds syncs for subdirs
|
||||
if isdir and recurse then
|
||||
addWatch(pd, true, raiseSync, raiseTime)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1505,7 +1510,7 @@ local Inotifies = (function()
|
||||
end
|
||||
lsyncd.inotifyrm(wd)
|
||||
wdpaths[wd] = nil
|
||||
pathwids[path] = nil
|
||||
pathwds[path] = nil
|
||||
end
|
||||
|
||||
-----
|
||||
|
@ -16,7 +16,8 @@ local trgdir = tdir.."trg/"
|
||||
|
||||
posix.mkdir(srcdir)
|
||||
posix.mkdir(trgdir)
|
||||
local pid = spawn("./lsyncd","-nodaemon","-rsync",srcdir,trgdir)
|
||||
--local pid = spawn("./lsyncd","-nodaemon","-rsync",srcdir,trgdir,"-log", "all")
|
||||
local pid = spawn("./lsyncd","-nodaemon","-rsync",srcdir,trgdir,"-log","all")
|
||||
|
||||
cwriteln("waiting for Lsyncd to startup")
|
||||
posix.sleep(1)
|
||||
|
Loading…
Reference in New Issue
Block a user