diff options
author | Vikas Gorur <vikas@gluster.com> | 2009-11-18 05:20:08 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-11-18 05:55:58 -0800 |
commit | 8f0ec7204d4b79dfb9fcf5f61df6275f6d4896fb (patch) | |
tree | 8a51c938bf6b039ce92d32486967e1341d028d1d /libglusterfs | |
parent | 4b233c6341134d11b170fa4cdbafc49246b46975 (diff) |
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 <vikas@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 394 (Possible deadlock in _gf_log)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=394
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/logging.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index c5ffedbeb..46b3ac5af 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); |