diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2014-06-23 12:09:30 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-06-30 03:44:00 -0700 |
commit | fe59c3485406cda02950e20f57d0ecc0cf964546 (patch) | |
tree | b1337e70e4785f76a83509ef8015d8d0de78b339 /xlators/debug/io-stats/src/io-stats.c | |
parent | 6a6bd449247cfed587922cbc1b6b54a1fa0301ad (diff) |
debug/io-stats: Free conf on init failures
Change-Id: I1d227f7b2b8f8ad8d44df8711654ee885e79cf38
BUG: 1111557
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/8148
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/debug/io-stats/src/io-stats.c')
-rw-r--r-- | xlators/debug/io-stats/src/io-stats.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index 6a2aa586ab1..8cc4bf13bf1 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -381,6 +381,7 @@ ios_stat_unref (struct ios_stat *iosstat) UNLOCK (&iosstat->lock); if (cleanup) { + LOCK_DESTROY (&iosstat->lock); GF_FREE (iosstat); iosstat = NULL; } @@ -2747,6 +2748,17 @@ mem_acct_init (xlator_t *this) return ret; } +void +ios_conf_destroy (struct ios_conf *conf) +{ + if (!conf) + return; + + ios_destroy_top_stats (conf); + LOCK_DESTROY (&conf->lock); + GF_FREE(conf); +} + int init (xlator_t *this) { @@ -2782,12 +2794,13 @@ init (xlator_t *this) conf = GF_CALLOC (1, sizeof(*conf), gf_io_stats_mt_ios_conf); - if (!conf) { - gf_log (this->name, GF_LOG_ERROR, - "Out of memory."); - return -1; - } + if (!conf) + goto out; + /* + * Init it just after calloc, so that we are sure the lock is inited + * in case of error paths. + */ LOCK_INIT (&conf->lock); gettimeofday (&conf->cumulative.started_at, NULL); @@ -2795,7 +2808,7 @@ init (xlator_t *this) ret = ios_init_top_stats (conf); if (ret) - return -1; + goto out; GF_OPTION_INIT ("dump-fd-stats", conf->dump_fd_stats, bool, out); @@ -2838,13 +2851,14 @@ init (xlator_t *this) this->private = conf; ret = 0; out: - if (!this->private) + if (!this->private) { + ios_conf_destroy (conf); ret = -1; + } return ret; } - void fini (xlator_t *this) { @@ -2854,15 +2868,9 @@ fini (xlator_t *this) return; conf = this->private; - - if (!conf) - return; this->private = NULL; - ios_destroy_top_stats (conf); - - GF_FREE(conf); - + ios_conf_destroy (conf); gf_log (this->name, GF_LOG_INFO, "io-stats translator unloaded"); return; |