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 /cli | |
| 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 'cli')
| -rw-r--r-- | cli/src/cli-rpc-ops.c | 2 | ||||
| -rw-r--r-- | cli/src/cli.c | 17 | 
2 files changed, 11 insertions, 8 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index ef0dd839cb7..92361e6debb 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -3730,7 +3730,7 @@ cmd_profile_volume_brick_out (dict_t *dict, int count, int interval)                  snprintf (key, sizeof (key), "%d-%d-%d-maxlatency", count,                            interval, i);                  ret = dict_get_double (dict, key, &profile_info[i].max_latency); -                profile_info[i].fop_name = gf_fop_list[i]; +                profile_info[i].fop_name = (char *)gf_fop_list[i];                  total_percentage_latency +=                         (profile_info[i].fop_hits * profile_info[i].avg_latency); diff --git a/cli/src/cli.c b/cli/src/cli.c index ccbc88f02e6..380a57f4896 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -173,12 +173,12 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)  static int -logging_init (struct cli_state *state) +logging_init (glusterfs_ctx_t *ctx, struct cli_state *state)  {          char *log_file = state->log_file ? state->log_file :                           DEFAULT_CLI_LOG_FILE_DIRECTORY "/cli.log"; -        if (gf_log_init (log_file) == -1) { +        if (gf_log_init (ctx, log_file) == -1) {                  fprintf (stderr, "ERROR: failed to open logfile %s\n",                           log_file);                  return -1; @@ -548,13 +548,16 @@ main (int argc, char *argv[])          int                ret = -1;          glusterfs_ctx_t   *ctx = NULL; -        ret = glusterfs_globals_init (); -        if (ret) -                return ret; -          ctx = glusterfs_ctx_new ();          if (!ctx)                  return ENOMEM; + +        gf_mem_acct_enable_set (ctx); + +        ret = glusterfs_globals_init (ctx); +        if (ret) +                return ret; +  	THIS->ctx = ctx;          ret = glusterfs_ctx_defaults_init (ctx); @@ -572,7 +575,7 @@ main (int argc, char *argv[])          if (ret)                  goto out; -        ret = logging_init (&state); +        ret = logging_init (ctx, &state);          if (ret)                  goto out;  | 
