From 8f0ec7204d4b79dfb9fcf5f61df6275f6d4896fb Mon Sep 17 00:00:00 2001 From: Vikas Gorur Date: Wed, 18 Nov 2009 05:20:08 +0000 Subject: libglusterfs: Fix error handling in _gf_log. Unlock the mutex when an error occurs instead of jumping straight to "out". Signed-off-by: Vikas Gorur Signed-off-by: Anand V. Avati BUG: 394 (Possible deadlock in _gf_log) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=394 --- libglusterfs/src/logging.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index c5ffedbeb23..46b3ac5afc1 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -494,12 +494,12 @@ log: basename, line, function, domain); if (-1 == ret) { - goto out; + goto unlock; } ret = vasprintf (&str2, fmt, ap); if (-1 == ret) { - goto out; + goto unlock; } va_end (ap); @@ -513,9 +513,10 @@ log: fprintf (logfile, "%s\n", msg); fflush (logfile); } +unlock: pthread_mutex_unlock (&logfile_mutex); - if (__central_log_enabled && + if ((ret != -1) && __central_log_enabled && ((glusterfs_central_log_flag_get ()) == 0)) { glusterfs_central_log_flag_set (); @@ -524,11 +525,15 @@ log: } glusterfs_central_log_flag_unset (); } - - FREE (msg); - FREE (str1); - FREE (str2); + if (msg) + FREE (msg); + + if (str1) + FREE (str1); + + if (str2) + FREE (str2); out: return (0); -- cgit