mirror of
https://github.com/troglobit/finit.git
synced 2026-11-11 16:40:48 +00:00
Only reload .conf and services if any .conf file has changed
This patch is an optimization. Now that we monitor for any .conf file changes (as soon as the event loop starts) we can skip automatic reload of all .conf files and services if no .conf file has changed. Unless the user issues an `initctl reload`, `init q`, or sends us SIGHUP. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
33ce746e58
commit
f2d142ef57
4 files changed
+14
-3
No files matched your search
@@ -633,6 +633,14 @@ static int do_change(char *name, uint32_t mask)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int conf_any_change(void)
|
||||||
|
{
|
||||||
|
if (TAILQ_EMPTY(&conf_change_list))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int conf_changed(char *file)
|
int conf_changed(char *file)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ char *rlim2str(int rlim);
|
|||||||
|
|
||||||
int conf_init (void);
|
int conf_init (void);
|
||||||
void conf_reload (void);
|
void conf_reload (void);
|
||||||
|
int conf_any_change (void);
|
||||||
int conf_changed (char *file);
|
int conf_changed (char *file);
|
||||||
int conf_monitor (uev_ctx_t *ctx);
|
int conf_monitor (uev_ctx_t *ctx);
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -291,13 +291,15 @@ static void finalize(void)
|
|||||||
if (runparts && fisdir(runparts)) {
|
if (runparts && fisdir(runparts)) {
|
||||||
_d("Running startup scripts in %s ...", runparts);
|
_d("Running startup scripts in %s ...", runparts);
|
||||||
run_parts(runparts, NULL);
|
run_parts(runparts, NULL);
|
||||||
service_reload_dynamic();
|
if (conf_any_change())
|
||||||
|
service_reload_dynamic();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convenient SysV compat for when you just don't care ... */
|
/* Convenient SysV compat for when you just don't care ... */
|
||||||
if (!access(FINIT_RC_LOCAL, X_OK)) {
|
if (!access(FINIT_RC_LOCAL, X_OK)) {
|
||||||
run_interactive(FINIT_RC_LOCAL, "Calling %s", FINIT_RC_LOCAL);
|
run_interactive(FINIT_RC_LOCAL, "Calling %s", FINIT_RC_LOCAL);
|
||||||
service_reload_dynamic();
|
if (conf_any_change())
|
||||||
|
service_reload_dynamic();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hooks that should run at the very end */
|
/* Hooks that should run at the very end */
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ restart:
|
|||||||
erase("/etc/nologin");
|
erase("/etc/nologin");
|
||||||
|
|
||||||
/* Make sure to (re)load all *.conf in /etc/finit.d/ */
|
/* Make sure to (re)load all *.conf in /etc/finit.d/ */
|
||||||
if (runlevel != 0 && runlevel != 6)
|
if (conf_any_change())
|
||||||
conf_reload();
|
conf_reload();
|
||||||
|
|
||||||
/* Reset once flag of runtasks */
|
/* Reset once flag of runtasks */
|
||||||
|
|||||||
Reference in new issue
Block a user