mirror of
https://github.com/octoleo/lsyncd.git
synced 2025-01-23 15:18:37 +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.
|
* Reads the directories entries.
|
||||||
* XXX
|
*
|
||||||
* @param (Lua stack) absolute path to directory.
|
* @param (Lua stack) absolute path to directory.
|
||||||
* @return (Lua stack) a table of directory names.
|
* @return (Lua stack) a table of directory names.
|
||||||
* names are keys, values are boolean
|
* names are keys, values are boolean
|
||||||
@ -1332,6 +1332,15 @@ masterloop(lua_State *L)
|
|||||||
/* nothing more inotify */
|
/* nothing more inotify */
|
||||||
break;
|
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) {
|
while (i < len && !hup && !term) {
|
||||||
struct inotify_event *event =
|
struct inotify_event *event =
|
||||||
(struct inotify_event *) &readbuf[i];
|
(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
|
-- registers and adds watches for all subdirectories
|
||||||
-- and/or raises create events for all entries
|
-- and/or raises create events for all entries
|
||||||
if recurse or raise then
|
if not recurse and not raise then
|
||||||
local entries = lsyncd.readdir(path)
|
return
|
||||||
for dirname, isdir in pairs(entries) do
|
end
|
||||||
local pd = path .. dirname
|
|
||||||
if isdir then
|
|
||||||
pd = pd .. "/"
|
|
||||||
end
|
|
||||||
|
|
||||||
-- creates a Create event for entry.
|
local entries = lsyncd.readdir(path)
|
||||||
if raiseSync then
|
if not entries then
|
||||||
raiseSync:delay("Create", raiseTime, pd, nil)
|
return
|
||||||
end
|
end
|
||||||
-- adds syncs for subdirs
|
for dirname, isdir in pairs(entries) do
|
||||||
if isdir and recurse then
|
local pd = path .. dirname
|
||||||
addWatch(pd, true, raiseSync, raiseTime)
|
if isdir then
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1505,7 +1510,7 @@ local Inotifies = (function()
|
|||||||
end
|
end
|
||||||
lsyncd.inotifyrm(wd)
|
lsyncd.inotifyrm(wd)
|
||||||
wdpaths[wd] = nil
|
wdpaths[wd] = nil
|
||||||
pathwids[path] = nil
|
pathwds[path] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
@ -16,7 +16,8 @@ local trgdir = tdir.."trg/"
|
|||||||
|
|
||||||
posix.mkdir(srcdir)
|
posix.mkdir(srcdir)
|
||||||
posix.mkdir(trgdir)
|
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")
|
cwriteln("waiting for Lsyncd to startup")
|
||||||
posix.sleep(1)
|
posix.sleep(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user