diff options
| author | Amar Tumballi <amarts@redhat.com> | 2012-08-02 13:14:25 +0530 | 
|---|---|---|
| committer | Anand Avati <avati@redhat.com> | 2012-08-03 02:01:52 -0700 | 
| commit | ed4b76ba9c545f577287c0e70ae3cc853a0d5f3f (patch) | |
| tree | deffb91a0cee620ac7fcc8c7914dbca73668574e /libglusterfs/src/mem-pool.c | |
| parent | 66205114267ec659b4ad8084c7e9497009529c61 (diff) | |
 core: reduce the usage of global variables
* move all the 'logging' related global variables into ctx
* make gf_fop_list a 'const' global array, hence no init(),
  no edits.
* make sure ctx is allocated without any dependancy on
  memory-accounting infrastructure, so it can be the first
  one to get allocated
* globals_init() should happen with ctx as argument
not yet fixed below in this patchset:
* anything with 'THIS' related globals
* anything related to compat_errno related globals as its
  one time init'd and not changed later on.
* statedump related globals
Change-Id: Iab8fc30d4bfdbded6741d66ff1ed670fdc7b7ad2
Signed-off-by: Amar Tumballi <amarts@redhat.com>
BUG: 764890
Reviewed-on: http://review.gluster.com/3767
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs/src/mem-pool.c')
| -rw-r--r-- | libglusterfs/src/mem-pool.c | 26 | 
1 files changed, 10 insertions, 16 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c index 50f8fef5a13..755e739449b 100644 --- a/libglusterfs/src/mem-pool.c +++ b/libglusterfs/src/mem-pool.c @@ -30,22 +30,16 @@  #define GLUSTERFS_ENV_MEM_ACCT_STR  "GLUSTERFS_DISABLE_MEM_ACCT" -static int gf_mem_acct_enable = 0; - -int -gf_mem_acct_is_enabled () -{ -        return gf_mem_acct_enable; -} - -  void -gf_mem_acct_enable_set () +gf_mem_acct_enable_set (void *data)  {          char            *opt = NULL;          long             val = -1; +        glusterfs_ctx_t *ctx = NULL; + +        ctx = data; -        if (gf_mem_acct_enable) { +        if (ctx->mem_acct_enable) {                  return;          } @@ -53,7 +47,7 @@ gf_mem_acct_enable_set ()          if (opt) {                  val = strtol (opt, NULL, 0);                  if (val) -                        gf_mem_acct_enable = 1; +                        ctx->mem_acct_enable = 1;          }          return; @@ -115,7 +109,7 @@ __gf_calloc (size_t nmemb, size_t size, uint32_t type)          char            *ptr = NULL;          xlator_t        *xl = NULL; -        if (!gf_mem_acct_enable) +        if (!THIS->ctx->mem_acct_enable)                  return CALLOC (nmemb, size);          xl = THIS; @@ -141,7 +135,7 @@ __gf_malloc (size_t size, uint32_t type)          char            *ptr = NULL;          xlator_t        *xl = NULL; -        if (!gf_mem_acct_enable) +        if (!THIS->ctx->mem_acct_enable)                  return MALLOC (size);          xl = THIS; @@ -166,7 +160,7 @@ __gf_realloc (void *ptr, size_t size)          xlator_t        *xl = NULL;          uint32_t        type = 0; -        if (!gf_mem_acct_enable) +        if (!THIS->ctx->mem_acct_enable)                  return REALLOC (ptr, size);          tot_size = size + GF_MEM_HEADER_SIZE + GF_MEM_TRAILER_SIZE; @@ -239,7 +233,7 @@ __gf_free (void *free_ptr)          uint32_t        type = 0;          xlator_t        *xl = NULL; -        if (!gf_mem_acct_enable) { +        if (!THIS->ctx->mem_acct_enable) {                  FREE (free_ptr);                  return;          }  | 
