diff options
author | Amar Tumballi <amarts@redhat.com> | 2012-03-15 14:00:13 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-03-15 03:33:18 -0700 |
commit | 5e50175f56d05ab6c1295b0e0f0c11695e49c277 (patch) | |
tree | 9ed89fa4a106939578d271297fbc94e8ead7c32d /libglusterfs/src/mem-pool.c | |
parent | eb8a9aae19755bc21afe2d8ed4893b788c4e84ff (diff) |
core: bring a cmdline option to set memory-accounting
currently this is implemented as a command line option, and not
as an easier translator option. this is because as of now, before
even the volume files are parsed, we would need memory accounting
enabled. there is scope for improving this behavior, but for now,
this approach solves the problem.
Also, this feature's major consumers are the testers who are
looking for leaks, hence option is hidden from usage output.
Change-Id: I09a5b13743ae43ff42c251989f921319e94cabe3
Signed-off-by: Amar Tumballi <amarts@redhat.com>
BUG: 799199
Reviewed-on: http://review.gluster.com/2856
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'libglusterfs/src/mem-pool.c')
-rw-r--r-- | libglusterfs/src/mem-pool.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c index 0cfd8bd712a..7f20d6d4b36 100644 --- a/libglusterfs/src/mem-pool.c +++ b/libglusterfs/src/mem-pool.c @@ -50,26 +50,31 @@ gf_mem_acct_is_enabled () void gf_mem_acct_enable_set () { - char *opt = NULL; - long val = -1; - #ifdef DEBUG gf_mem_acct_enable = 1; return; #endif + glusterfs_ctx_t *ctx = NULL; + char *opt = NULL; + long val = -1; - opt = getenv (GLUSTERFS_ENV_MEM_ACCT_STR); - - if (!opt) - return; + gf_mem_acct_enable = 0; - val = strtol (opt, NULL, 0); + ctx = glusterfs_ctx_get (); - if (val) - gf_mem_acct_enable = 0; - else + if (ctx->mem_accounting) { gf_mem_acct_enable = 1; + return; + } + opt = getenv (GLUSTERFS_ENV_MEM_ACCT_STR); + if (opt) { + val = strtol (opt, NULL, 0); + if (val) + gf_mem_acct_enable = 1; + } + + return; } void |