From a78b0af5eab65e1567ecd3c9a7151cc4a5030f92 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Tue, 14 Feb 2012 20:27:16 +0000 Subject: Re-commit the verbose branch. This change permits each verbose destination (consoles, logger) to have its own concept of what the verbosity level is. The big feature here is that the logger will now be able to capture a particular verbosity level without condemning each console to need to suffer that level of verbosity. Additionally, a stray 'core set verbose' will no longer change what will go to the log. Review: https://reviewboard.asterisk.org/r/1599/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@355413 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/stdtime/localtime.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'main/stdtime') diff --git a/main/stdtime/localtime.c b/main/stdtime/localtime.c index 4e0fd760c..dff06eedc 100644 --- a/main/stdtime/localtime.c +++ b/main/stdtime/localtime.c @@ -261,6 +261,19 @@ static AST_LIST_HEAD_STATIC(localelist, locale_entry); static pthread_t inotify_thread = AST_PTHREADT_NULL; static ast_cond_t initialization; static ast_mutex_t initialization_lock; + +static void add_notify(struct state *sp, const char *path); + +/*! Start a notification for every entry already in the list. */ +static void common_startup(void) { + struct state *sp; + AST_LIST_LOCK(&zonelist); + AST_LIST_TRAVERSE(&zonelist, sp, list) { + add_notify(sp, sp->name); + } + AST_LIST_UNLOCK(&zonelist); +} + #ifdef HAVE_INOTIFY static int inotify_fd = -1; @@ -285,6 +298,8 @@ static void *inotify_daemon(void *data) return NULL; } + common_startup(); + for (;/*ever*/;) { /* This read should block, most of the time. */ if ((res = read(inotify_fd, &buf, sizeof(buf))) < sizeof(buf.iev) && res > 0) { @@ -378,6 +393,8 @@ static void *kqueue_daemon(void *data) ast_cond_signal(&initialization); ast_mutex_unlock(&initialization_lock); + common_startup(); + for (;/*ever*/;) { if (kevent(queue_fd, NULL, 0, &kev, 1, NULL) < 0) { AST_LIST_LOCK(&zonelist); @@ -538,6 +555,8 @@ static void *notify_daemon(void *data) ast_cond_broadcast(&initialization); ast_mutex_unlock(&initialization_lock); + common_startup(); + for (;/*ever*/;) { char fullname[FILENAME_MAX + 1]; @@ -703,7 +722,14 @@ static int tzload(const char *name, struct state * const sp, const int doextend) return -1; if ((fid = open(name, OPEN_MODE)) == -1) return -1; - add_notify(sp, name); + if (ast_fully_booted) { + /* If we don't wait until Asterisk is fully booted, it's possible + * that the watcher thread gets started in the parent process, + * before daemon(3) is called, and the thread won't propagate to + * the child. Given that bootup only takes a few seconds, it's + * reasonable to only start the watcher later. */ + add_notify(sp, name); + } } nread = read(fid, u.buf, sizeof u.buf); if (close(fid) < 0 || nread <= 0) -- cgit v1.2.3