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:
Joachim Nilsson committed 2017-12-29 19:22:01 +01:00
1 parent 33ce746e58
commit f2d142ef57
4 files changed
+14 -3

No files matched your search

+8
View File
@@ -633,6 +633,14 @@ static int do_change(char *name, uint32_t mask)
return 0;
}
int conf_any_change(void)
{
if (TAILQ_EMPTY(&conf_change_list))
return 0;
return 1;
}
int conf_changed(char *file)
{
char *ptr;
+1
View File
@@ -33,6 +33,7 @@ char *rlim2str(int rlim);
int conf_init (void);
void conf_reload (void);
int conf_any_change (void);
int conf_changed (char *file);
int conf_monitor (uev_ctx_t *ctx);
+4 -2
View File
@@ -291,13 +291,15 @@ static void finalize(void)
if (runparts && fisdir(runparts)) {
_d("Running startup scripts in %s ...", runparts);
run_parts(runparts, NULL);
service_reload_dynamic();
if (conf_any_change())
service_reload_dynamic();
}
/* Convenient SysV compat for when you just don't care ... */
if (!access(FINIT_RC_LOCAL, X_OK)) {
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 */
+1 -1
View File
@@ -143,7 +143,7 @@ restart:
erase("/etc/nologin");
/* Make sure to (re)load all *.conf in /etc/finit.d/ */
if (runlevel != 0 && runlevel != 6)
if (conf_any_change())
conf_reload();
/* Reset once flag of runtasks */