From c7d11e4eef3ac93309a54817cf25ada19b12237f Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Mon, 29 Aug 2011 09:21:40 +0000 Subject: [PATCH] imply --insist on reset --- lsyncd.c | 20 ++++++++++++-------- lsyncd.lua | 12 ++++++++++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/lsyncd.c b/lsyncd.c index e971a9c..5215b44 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -128,12 +128,15 @@ struct settings settings = { static bool is_daemon = false; /** - * True after first configuration phase. This is to write configuration error - * messages to stdout/stderr after being first started. Then it uses whatever - * it has been configured to. This survives a reset by HUP signal or - * inotify OVERFLOW. + * False after first time Lsyncd started up. + * + * Thus configuration error messages are written to stdout/stderr only on + * first start. + * + * All other resets (HUP or inotify OVERFLOW) run with implictly --insist + * turned on and thus Lsyncd not failing on a not responding target. */ -static bool running = false; +static bool first_time = true; /** * Set to TERM or HUP in signal handler, when lsyncd should end or reset ASAP. @@ -288,7 +291,7 @@ logstring0(int priority, const char *cat, const char *message) if (priority < 0) { priority = LOG_DEBUG; } - if (!running) { + if (first_time) { /* lsyncd is in intial configuration. * thus just print to normal stdout/stderr. */ if (priority >= LOG_ERR) { @@ -1166,7 +1169,7 @@ l_configure(lua_State *L) /* set by runner after first initialize * from this on log to configurated log end instead of * stdout/stderr */ - running = true; + first_time = false; if (settings.log_syslog || !settings.log_file) { openlog(settings.log_ident ? settings.log_ident : "lsyncd", 0, @@ -1992,7 +1995,8 @@ main1(int argc, char *argv[]) /* runs initialitions from runner * lua code will set configuration and add watches */ load_runner_func(L, "initialize"); - if (lua_pcall(L, 0, 0, -2)) { + lua_pushboolean(L, first_time); + if (lua_pcall(L, 1, 0, -3)) { exit(-1); // ERRNO } lua_pop(L, 1); diff --git a/lsyncd.lua b/lsyncd.lua index bb46b8e..c07e0e0 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -2800,8 +2800,11 @@ end ---- -- Called from core on init or restart after user configuration. +-- +-- @firstTime true the first time Lsyncd startup, false on resets +-- due to HUP signal or monitor queue OVERFLOW. -- -function runner.initialize() +function runner.initialize(firstTime) -- creates settings if user didnt settings = settings or {} @@ -2816,13 +2819,18 @@ function runner.initialize() end settings[v]=true end - + -- all command line settings overwrite config file settings for k, v in pairs(clSettings) do if k ~= "syncs" then settings[k]=v end end + + -- implicitly force insist to be true on Lsyncd resets. + if not firstTime then + settings.insist = true + end -- adds syncs specified by command line. if clSettings.syncs then