changeset 307:a4592b91368c

Ensure cancellation-safe logs
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 08 Jan 2009 15:37:51 +0900
parents b9b74d6ac29e
children 7e2c809b7892
files waaad/log.c
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/waaad/log.c	Thu Jan 08 15:36:06 2009 +0900
+++ b/waaad/log.c	Thu Jan 08 15:37:51 2009 +0900
@@ -353,6 +353,8 @@
 		return;
 	}
 	
+	pthread_cleanup_push(cleanup_mutex, &log_mtx);
+	
 	if ( log_to & LOG_TO_SYSLOG ) {
 		va_start(ap, format);
 		vsyslog( LOG_ERR, format, ap);
@@ -371,6 +373,7 @@
 	}
 		
 	/* Unlock the mutex and return ret */
+	pthread_cleanup_pop(0);
 	(void) pthread_mutex_unlock(&log_mtx);
 	return;
 }
@@ -387,6 +390,8 @@
 		return;
 	}
 	
+	pthread_cleanup_push(cleanup_mutex, &log_mtx);
+	
 	if ( log_to & LOG_TO_SYSLOG ) {
 		va_start(ap, format);
 		vsyslog( LOG_INFO, format, ap);
@@ -405,6 +410,7 @@
 	}
 		
 	/* Unlock the mutex and return ret */
+	pthread_cleanup_pop(0);
 	(void) pthread_mutex_unlock(&log_mtx);
 	return;
 }
@@ -425,6 +431,8 @@
 		return;
 	}
 	
+	pthread_cleanup_push(cleanup_mutex, &log_mtx);
+	
 	if ( log_to & LOG_TO_SYSLOG ) {
 		va_start(ap, format);
 		vsyslog( LOG_DEBUG, format, ap);
@@ -443,6 +451,7 @@
 	}
 		
 	/* Unlock the mutex and return ret */
+	pthread_cleanup_pop(0);
 	(void) pthread_mutex_unlock(&log_mtx);
 	return;
 }
"Welcome to our mercurial repository"