[asterisk-commits] tilghman: branch tilghman/verbose r348792 - /team/tilghman/verbose/main/stdtime/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 21 14:08:42 CST 2011


Author: tilghman
Date: Wed Dec 21 14:08:39 2011
New Revision: 348792

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=348792
Log:
Better explain why this fix works, and add notifies for existing entries when the daemon starts.

Modified:
    team/tilghman/verbose/main/stdtime/localtime.c

Modified: team/tilghman/verbose/main/stdtime/localtime.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/verbose/main/stdtime/localtime.c?view=diff&rev=348792&r1=348791&r2=348792
==============================================================================
--- team/tilghman/verbose/main/stdtime/localtime.c (original)
+++ team/tilghman/verbose/main/stdtime/localtime.c Wed Dec 21 14:08:39 2011
@@ -261,6 +261,19 @@
 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;
 
@@ -284,6 +297,8 @@
 		inotify_thread = AST_PTHREADT_NULL;
 		return NULL;
 	}
+
+	common_startup();
 
 	for (;/*ever*/;) {
 		/* This read should block, most of the time. */
@@ -378,6 +393,8 @@
 	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);
@@ -537,6 +554,8 @@
 	ast_mutex_lock(&initialization_lock);
 	ast_cond_broadcast(&initialization);
 	ast_mutex_unlock(&initialization_lock);
+
+	common_startup();
 
 	for (;/*ever*/;) {
 		char		fullname[FILENAME_MAX + 1];
@@ -704,6 +723,11 @@
 		if ((fid = open(name, OPEN_MODE)) == -1)
 			return -1;
 		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);
 		}
 	}




More information about the asterisk-commits mailing list