[Asterisk-cvs] asterisk logger.c,1.26,1.26.2.1

markster at lists.digium.com markster at lists.digium.com
Tue Mar 30 11:19:25 CST 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv2402

Modified Files:
      Tag: v1-0_stable
	logger.c 
Log Message:
Indicate the need for a reload without actually executing it, since trying to grab a lock in a signal handler is a Bad Idea.


Index: logger.c
===================================================================
RCS file: /usr/cvsroot/asterisk/logger.c,v
retrieving revision 1.26
retrieving revision 1.26.2.1
diff -u -d -r1.26 -r1.26.2.1
--- logger.c	3 Feb 2004 16:43:07 -0000	1.26
+++ logger.c	30 Mar 2004 16:17:43 -0000	1.26.2.1
@@ -49,6 +49,7 @@
 
 static ast_mutex_t msglist_lock = AST_MUTEX_INITIALIZER;
 static ast_mutex_t loglock = AST_MUTEX_INITIALIZER;
+static int pending_logger_reload = 0;
 
 static struct msglist {
 	char *msg;
@@ -228,7 +229,6 @@
 	FILE *myf;
 
 	int x;
-
 	ast_mutex_lock(&loglock);
 	if (eventlog) 
 		fclose(eventlog);
@@ -295,6 +295,7 @@
 	} else 
 		ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
 	init_logger_chain();
+	pending_logger_reload = 0;
 	return -1;
 }
 
@@ -345,10 +346,8 @@
 	logger_rotate_help };
 
 static int handle_SIGXFSZ(int sig) {
-    reload_logger(1);
-    ast_log(LOG_EVENT,"Rotated Logs Per SIGXFSZ\n");
-    if (option_verbose)
-	    ast_verbose("Rotated Logs Per SIGXFSZ\n");
+	/* Indicate need to reload */
+	pending_logger_reload = 1;
     return 0;
 }
 
@@ -493,6 +492,12 @@
 
     ast_mutex_unlock(&loglock);
     /* end critical section */
+	if (pending_logger_reload) {
+	    reload_logger(1);
+	    ast_log(LOG_EVENT,"Rotated Logs Per SIGXFSZ\n");
+	    if (option_verbose)
+		    ast_verbose("Rotated Logs Per SIGXFSZ\n");
+	}
 }
 
 extern void ast_verbose(const char *fmt, ...)




More information about the svn-commits mailing list