From 288cf4ae616348b83bf3a028593622f31811d416 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Wed, 1 Dec 2010 13:17:04 +0000 Subject: [PATCH] upvalue save alarm comparison --- examples/lsayirc.lua | 4 ++-- lsyncd.c | 6 ++++++ lsyncd.lua | 20 +++++++++----------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/examples/lsayirc.lua b/examples/lsayirc.lua index d811c15..afbe8a8 100644 --- a/examples/lsayirc.lua +++ b/examples/lsayirc.lua @@ -1,7 +1,7 @@ require("socket") settings.nodaemon = true ---hostname = "irc.freenode.org" -hostname = "127.0.0.1" +hostname = "irc.freenode.org" +--hostname = "127.0.0.1" port = 6667 nick = "lbot01" chan = "##lfile01" diff --git a/lsyncd.c b/lsyncd.c index e5a86b4..b1541ad 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -1610,6 +1610,12 @@ masterloop(lua_State *L) return; } lua_pop(L, 2); + + if (lua_gettop(L)) { + logstring("Error", "internal, stack is dirty.") + l_stackdump(L); + exit(-1); // ERRNO + } } } diff --git a/lsyncd.lua b/lsyncd.lua index 3edef85..57fed0d 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -2620,29 +2620,27 @@ function runner.getAlarm() ---- -- checks if current nearest alarm or a is earlier -- - local function checkAlarm(a) + local function checkAlarm(alarm, a) if alarm == true or not a then -- already immediate or no new alarm - return + return alarm end - if not alarm then - alarm = a + -- returns the ealier time + if not alarm or a < alarm then + return a else - -- the earlier time - if a < alarm then - alarm = a - end + return alarm end end -- checks all syncs for their earliest alarm for _, s in Syncs.iwalk() do - checkAlarm(s:getAlarm()) + alarm = checkAlarm(alarm, s:getAlarm()) end -- checks if a statusfile write has been delayed - checkAlarm(StatusFile.getAlarm()) + alarm = checkAlarm(alarm, StatusFile.getAlarm()) -- checks for an userAlarm - checkAlarm(UserAlarms.getAlarm()) + alarm = checkAlarm(alarm, UserAlarms.getAlarm()) log("Debug","getAlarm returns: ",alarm) return alarm