This commit is contained in:
Axel Kittenberger 2010-11-12 20:55:22 +00:00
parent 9156f4c4c7
commit c84308b973
2 changed files with 42 additions and 25 deletions

View File

@ -1254,23 +1254,19 @@ masterloop(lua_State *L)
continue; continue;
} }
} while(0); } while(0);
if (len == 0) {
/* nothing more inotify */
break;
}
while (i < len && !reset) { while (i < len && !reset) {
struct inotify_event *event = struct inotify_event *event =
(struct inotify_event *) &readbuf[i]; (struct inotify_event *) &readbuf[i];
handle_event(L, event); handle_event(L, event);
i += sizeof(struct inotify_event) + event->len; i += sizeof(struct inotify_event) + event->len;
} }
/* check if there is more data */ if (!move_event) {
{ /* give it a pause if not endangering splitting a move */
struct timespec tv = {.tv_sec = 0, .tv_nsec = 0}; break;
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(inotify_fd, &readfds);
do_read = pselect(inotify_fd + 1, &readfds,
NULL, NULL, &tv, NULL) > 0;
if (do_read) {
logstring("Masterloop", "there is more data on inotify.");
}
} }
} }
/* checks if there is an unary MOVE_FROM left in the buffer */ /* checks if there is an unary MOVE_FROM left in the buffer */
@ -1573,6 +1569,7 @@ main(int argc, char *argv[])
return -1; // ERRNO return -1; // ERRNO
} }
close_exec_fd(inotify_fd); close_exec_fd(inotify_fd);
non_block_fd(inotify_fd);
{ {
/* adds signal handlers * /* adds signal handlers *

View File

@ -554,9 +554,9 @@ local Inlet, InletControl = (function()
end end
----- -----
-- Cancels a waiting event. -- Discards a waiting event.
-- --
local function cancelEvent(event) local function discardEvent(event)
local delay = e2d[event] local delay = e2d[event]
if delay.status ~= "wait" then if delay.status ~= "wait" then
log("Error", "Ignored try to cancel a non-waiting event of type ", log("Error", "Ignored try to cancel a non-waiting event of type ",
@ -889,9 +889,13 @@ local Sync = (function()
return return
end end
for _, d in ipairs(self.delays) do for _, d in ipairs(self.delays) do
if d.alarm ~= true and lsyncd.clockbefore(now, d.alarm) then if #self.delays < self.config.maxDelays then
-- reached point in stack where delays are in future -- time constrains only are only a concern if not maxed
return -- the delay FIFO already.
if d.alarm ~= true and lsyncd.clockbefore(now, d.alarm) then
-- reached point in stack where delays are in future
return
end
end end
if d.status == "wait" then if d.status == "wait" then
-- found a waiting delay -- found a waiting delay
@ -910,9 +914,13 @@ local Sync = (function()
-- --
local function getNextDelay(self, now) local function getNextDelay(self, now)
for i, d in ipairs(self.delays) do for i, d in ipairs(self.delays) do
if d.alarm ~= true and lsyncd.clockbefore(now, d.alarm) then if #self.delays < self.config.maxDelays then
-- reached point in stack where delays are in future -- time constrains only are only a concern if not maxed
return nil -- the delay FIFO already.
if d.alarm ~= true and lsyncd.clockbefore(now, d.alarm) then
-- reached point in stack where delays are in future
return nil
end
end end
if d.status == "wait" then if d.status == "wait" then
-- found a waiting delay -- found a waiting delay
@ -1071,10 +1079,15 @@ local Syncs = (function()
end end
-- loads a default value for an option if not existent -- loads a default value for an option if not existent
local defaultValues = local defaultValues = {
{'action', 'collapse', 'collapseTable', 'action',
'collect', 'maxProcesses', 'init' 'collapse',
} 'collapseTable',
'collect',
'init',
'maxDelays',
'maxProcesses',
}
for _, dn in pairs(defaultValues) do for _, dn in pairs(defaultValues) do
if config[dn] == nil then if config[dn] == nil then
config[dn] = settings[dn] or default[dn] config[dn] = settings[dn] or default[dn]
@ -1766,7 +1779,7 @@ default = {
-- if function didnt change the wait status its not interested -- if function didnt change the wait status its not interested
-- in this event -> drop it. -- in this event -> drop it.
if event.status == "wait" then if event.status == "wait" then
inlet.cancelEvent(event) inlet.discardEvent(event)
end end
end, end,
@ -1857,7 +1870,7 @@ default = {
if event.status == "wait" then if event.status == "wait" then
-- user script did not spawn anything -- user script did not spawn anything
-- thus the blanket event is deleted again. -- thus the blanket event is deleted again.
inlet.cancelEvent(event) inlet.discardEvent(event)
end end
-- TODO honor some return codes of startup like "warmstart". -- TODO honor some return codes of startup like "warmstart".
end end
@ -1869,6 +1882,13 @@ default = {
-- --
maxProcesses = 1, maxProcesses = 1,
-----
-- Try not to have more than these delays.
-- not too large, since total calculation for stacking
-- events is n*log(n) or so..
--
maxDelays = 1000,
----- -----
-- a default rsync configuration for easy usage. -- a default rsync configuration for easy usage.
-- --