[asterisk-commits] mjordan: branch mjordan/trunk-deadlock r376616 - /team/mjordan/trunk-deadlock...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 22 20:20:34 CST 2012


Author: mjordan
Date: Thu Nov 22 20:20:30 2012
New Revision: 376616

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=376616
Log:
Move makesocket back to where it started.  Try pthread_atfork.

Modified:
    team/mjordan/trunk-deadlock/main/asterisk.c
    team/mjordan/trunk-deadlock/main/lock.c

Modified: team/mjordan/trunk-deadlock/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-deadlock/main/asterisk.c?view=diff&rev=376616&r1=376615&r2=376616
==============================================================================
--- team/mjordan/trunk-deadlock/main/asterisk.c (original)
+++ team/mjordan/trunk-deadlock/main/asterisk.c Thu Nov 22 20:20:30 2012
@@ -3533,6 +3533,16 @@
 	setenv("AST_VERSION", ast_get_version(), 1);
 }
 
+#if defined(HAVE_WORKING_FORK) && !defined(HAVE_SBIN_LAUNCHD)
+
+static void fork_fixup(void)
+{
+	ast_rwlock_destroy(&thread_list.lock);
+	ast_rwlock_init(&thread_list.lock);
+}
+
+#endif
+
 static void print_intro_message(const char *runuser, const char *rungroup)
 {
 	if (ast_opt_console || option_verbose) {
@@ -3952,6 +3962,7 @@
 #if HAVE_WORKING_FORK
 	if (ast_opt_always_fork || !ast_opt_no_fork) {
 #ifndef HAVE_SBIN_LAUNCHD
+		pthread_atfork(NULL, NULL, fork_fixup);
 		if (daemon(1, 0) < 0) {
 			fprintf(stderr, "daemon() failed: %s\n", strerror(errno));
 		}
@@ -4084,6 +4095,7 @@
 
 	ast_aoc_cli_init();
 
+	ast_makesocket();
 	sigemptyset(&sigs);
 	sigaddset(&sigs, SIGHUP);
 	sigaddset(&sigs, SIGTERM);
@@ -4236,8 +4248,6 @@
 		exit(1);
 	}
 	
-	ast_makesocket();
-
 	if ((moduleresult = load_modules(0))) {		/* Load modules */
 		printf("%s", term_quit());
 		exit(moduleresult == -2 ? 2 : 1);

Modified: team/mjordan/trunk-deadlock/main/lock.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/trunk-deadlock/main/lock.c?view=diff&rev=376616&r1=376615&r2=376616
==============================================================================
--- team/mjordan/trunk-deadlock/main/lock.c (original)
+++ team/mjordan/trunk-deadlock/main/lock.c Thu Nov 22 20:20:30 2012
@@ -750,7 +750,7 @@
 		__ast_mutex_logger("%s line %d (%s): Error destroying rwlock %s: %s\n",
 				filename, lineno, func, rwlock_name, strerror(res));
 	}
-	if (t->tracking) {
+	if (t->tracking && lt) {
 		ast_reentrancy_lock(lt);
 		lt->file[0] = filename;
 		lt->lineno[0] = lineno;




More information about the asterisk-commits mailing list