.conf: don't rely on mtime to determine if service needs reloading

Until now Finit has used mtime to determine if a file has been changed,
or simply touched to request reload, when `initctl reload` is called.
Using mtime for this purpose is a monumentally bad idea since time can
be changed at any point: a user may adjust the time, NTP continously
tunes the clock, and time stamps are stored as the walltime.  So if we
compare timestamps against the last time we (booted or) did reload, we
would miss .conf file changes.

This patch replaces the mtime mistake with an inotify watcher for the
following files: /etc/finit.d/*.conf, /etc/finit.d/available/*.conf,
and /etc/finit.conf.  All file changes between (bootstraps and) calls
to `initctl reload` are tracked, like the mtime backend it replaces.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-12-22 13:08:38 +01:00
1 parent bb3d9c8670
commit b439ac670d
10 files changed
+261 -90

No files matched your search

+1 -3
View File
@@ -54,7 +54,6 @@ typedef struct tty_node {
finit_tty_t data;
/* XXX: Yes, TTYs should be refactored into a separate SVC type. */
struct timeval mtime; /* Modification time for .conf from /etc/finit.d/ */
int dirty; /* Set if old mtime != new mtime => reloaded,
* or -1 when marked for removal */
} tty_node_t;
@@ -62,10 +61,9 @@ typedef struct tty_node {
//extern LIST_HEAD(, tty_node) tty_list;
void tty_mark (void);
void tty_check (tty_node_t *tty, struct timeval *mtime);
void tty_sweep (void);
int tty_register (char *line, struct rlimit rlimit[], struct timeval *mtime);
int tty_register (char *line, struct rlimit rlimit[], char *file);
int tty_unregister (tty_node_t *tty);
tty_node_t *tty_find (char *dev);