commit 4eda62456740461f378ac5350e35f0f6b56021f9
parent fc8c4cf95034e305b65ef22f59b8b20631015c6c
Author: Joris Vink <joris@coders.se>
Date: Tue, 24 Apr 2018 23:00:53 +0200
only reload users if the users.conf changed
Diffstat:
1 file changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/blog.c b/src/blog.c
@@ -108,6 +108,7 @@ int list_posts(struct http_request *, const char *, struct cache **, int);
static TAILQ_HEAD(, post) posts;
static TAILQ_HEAD(, user) users;
static volatile sig_atomic_t blog_sig = -1;
+static time_t user_mtime = 0;
static struct cache *live_index = NULL;
static struct cache *draft_index = NULL;
@@ -208,12 +209,24 @@ fts_compare(const FTSENT **a, const FTSENT **b)
void
user_reload(void)
{
+ struct stat st;
FILE *fp;
u_int32_t uids;
struct user *user;
int lineno;
char *line, *pwd, buf[256];
+ if (stat(BLOG_USER_CONF, &st) == -1) {
+ if (errno != ENOENT) {
+ kore_log(LOG_INFO,
+ "stat(%s): %s", BLOG_USER_CONF, errno_s);
+ }
+ return;
+ }
+
+ if (user_mtime == st.st_mtime)
+ return;
+
while (!TAILQ_EMPTY(&users)) {
user = TAILQ_FIRST(&users);
TAILQ_REMOVE(&users, user, list);
@@ -232,6 +245,8 @@ user_reload(void)
return;
}
+ kore_log(LOG_INFO, "reloading users");
+
uids = 1;
lineno = 0;
@@ -261,6 +276,7 @@ user_reload(void)
}
fclose(fp);
+ user_mtime = st.st_mtime;
}
void