This commit is contained in:
Axel Kittenberger 2010-11-05 18:20:33 +00:00
parent 081c20dc33
commit c877ec25d9
3 changed files with 27 additions and 19 deletions

View File

@ -9,7 +9,7 @@ settings = {
statusfile = "/tmp/lsyncd.stat", statusfile = "/tmp/lsyncd.stat",
} }
------ ----
-- for testing purposes. uses bash command to hold local dirs in sync. -- for testing purposes. uses bash command to hold local dirs in sync.
-- --
prefix = "sleep 1 && " prefix = "sleep 1 && "

View File

@ -1093,12 +1093,14 @@ masterloop(lua_State *L)
printlogf(L, "Call", "lsycnd_get_alarm()"); printlogf(L, "Call", "lsycnd_get_alarm()");
lua_getglobal(L, "lsyncd_call_error"); lua_getglobal(L, "lsyncd_call_error");
lua_getglobal(L, "lsyncd_get_alarm"); lua_getglobal(L, "lsyncd_get_alarm");
if (lua_pcall(L, 0, 2, -2)) { if (lua_pcall(L, 0, 1, -2)) {
exit(-1); // ERRNO exit(-1); // ERRNO
} }
have_alarm = lua_toboolean(L, -2); have_alarm = lua_toboolean(L, -1);
if (have_alarm) {
alarm_time = (clock_t) luaL_checkinteger(L, -1); alarm_time = (clock_t) luaL_checkinteger(L, -1);
lua_pop(L, 3); }
lua_pop(L, 2);
if (have_alarm && time_before_eq(alarm_time, now)) { if (have_alarm && time_before_eq(alarm_time, now)) {
/* there is a delay that wants to be handled already thus do not /* there is a delay that wants to be handled already thus do not

View File

@ -22,6 +22,14 @@ if lsyncd_version then
end end
lsyncd_version = "2.0beta1" lsyncd_version = "2.0beta1"
-----
-- Hides the core interface from user scripts
--
_l = lsyncd
lsyncd = nil
local lsyncd = _l
_l = nil
---- ----
-- Shortcuts (which user is supposed to be able to use them as well) -- Shortcuts (which user is supposed to be able to use them as well)
-- --
@ -578,9 +586,8 @@ function lsyncd_collect_process(pid, exitcode)
if not delay then if not delay then
return return
end end
log("Debug", "collected ", pid, ": ", log("Debug", "collected ",pid, ": ",delay.ename," of ",
delay.ename, " of ", origin.source, delay.pathname, origin.source,delay.pathname," = ",exitcode)
" = ", exitcode)
origin.processes[pid] = nil origin.processes[pid] = nil
end end
@ -598,7 +605,9 @@ local Inlet, inlet_control = (function()
-- event to be passed to the user -- event to be passed to the user
local event = {} local event = {}
-- TODO -----
-- Interface for the user to get fields.
--
local event_fields = { local event_fields = {
config = function() config = function()
return origin.config return origin.config
@ -891,27 +900,24 @@ end
---- ----
-- Called by core to query soonest alarm. -- Called by core to query soonest alarm.
-- --
-- @return two variables. -- @return false ... no alarm, core can in untimed sleep, or
-- boolean false ... no alarm, core can in untimed sleep
-- true ... alarm time specified.
-- times ... the alarm time (only read if number is 1) -- times ... the alarm time (only read if number is 1)
--
function lsyncd_get_alarm() function lsyncd_get_alarm()
local have_alarm = false local alarm = false
local alarm = 0
for _, o in Origins.iwalk() do for _, o in Origins.iwalk() do
-- TODO better handling of stati. -- TODO better handling of stati.
if o.delays[1] and if o.delays[1] and
o.processes:size() < o.config.max_processes then o.processes:size() < o.config.max_processes then
if have_alarm then if alarm then
alarm = lsyncd.earlier(alarm, o.delays[1].alarm) alarm = lsyncd.earlier(alarm, o.delays[1].alarm)
else else
alarm = o.delays[1].alarm alarm = o.delays[1].alarm
have_alarm = true
end end
end end
end end
log("Debug", "lysncd_get_alarm returns: ",have_alarm,", ",alarm) log("Debug", "lysncd_get_alarm returns: ",alarm)
return have_alarm, alarm return alarm
end end
lsyncd_inotify_event = Inotifies.event lsyncd_inotify_event = Inotifies.event