[luad] move the #restarts check to the end of the loop, so that it does not get triggered when booting in the first 60secs of epoch time

This commit is contained in:
Bart Van Der Meerssche 2011-04-18 21:34:52 +02:00
parent 91408ddac0
commit b799e4629c
1 changed files with 11 additions and 11 deletions

View File

@ -339,13 +339,7 @@ int main(int argc, char *argv[])
struct restart_s restart; struct restart_s restart;
restart_init(&restart); restart_init(&restart);
while(1) { do {
/* Stop when allowed number of restarts have occurred in specified time window */
if (restart_max(&restart)) {
daemon_log(LOG_ERR, "%d restarts within a %d sec window", SUP_ALLOWED_RESTARTS, SUP_MAX_SECONDS);
break;
}
/* Create a new Lua environment */ /* Create a new Lua environment */
L = luaL_newstate(); L = luaL_newstate();
/* And load the standard libraries into the Lua environment */ /* And load the standard libraries into the Lua environment */
@ -356,11 +350,17 @@ int main(int argc, char *argv[])
} }
/* Clean up the Lua state */ /* Clean up the Lua state */
lua_close(L); lua_close(L);
/* Wait for one second before restarting the Lua daemon */
sleep(1);
restart_add(&restart, time(NULL));
}
/* Wait for one second before restarting the Lua daemon */
restart_add(&restart, time(NULL));
sleep(1);
} while (!restart_max(&restart));
/* Stop when allowed number of restarts have occurred in specified time window */
daemon_log(LOG_ERR, "%d restarts within a %d sec window", SUP_ALLOWED_RESTARTS, SUP_MAX_SECONDS);
/* Do a cleanup */ /* Do a cleanup */
finish: finish:
daemon_log(LOG_INFO, "Exiting..."); daemon_log(LOG_INFO, "Exiting...");