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/common-utils.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/common-utils.c')
| -rw-r--r-- | libglusterfs/src/common-utils.c | 21 | 
1 files changed, 11 insertions, 10 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 74f38d01ea9..cf5991e1084 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -239,24 +239,26 @@ err:  void  gf_log_volume_file (FILE *specfp)  { -        extern FILE *gf_log_logfile;          int          lcount = 0;          char         data[GF_UNIT_KB]; +        glusterfs_ctx_t *ctx; + +        ctx = THIS->ctx;          fseek (specfp, 0L, SEEK_SET); -        fprintf (gf_log_logfile, "Given volfile:\n"); -        fprintf (gf_log_logfile, +        fprintf (ctx->log.gf_log_logfile, "Given volfile:\n"); +        fprintf (ctx->log.gf_log_logfile,                   "+---------------------------------------"                   "---------------------------------------+\n");          while (fgets (data, GF_UNIT_KB, specfp) != NULL){                  lcount++; -                fprintf (gf_log_logfile, "%3d: %s", lcount, data); +                fprintf (ctx->log.gf_log_logfile, "%3d: %s", lcount, data);          } -        fprintf (gf_log_logfile, +        fprintf (ctx->log.gf_log_logfile,                   "\n+---------------------------------------"                   "---------------------------------------+\n"); -        fflush (gf_log_logfile); +        fflush (ctx->log.gf_log_logfile);          fseek (specfp, 0L, SEEK_SET);  } @@ -396,13 +398,12 @@ out:  void  gf_print_trace (int32_t signum, glusterfs_ctx_t *ctx)  { -        extern FILE *gf_log_logfile;          char         msg[1024] = {0,};          char         timestr[64] = {0,};          int          ret = 0;          int          fd = 0; -        fd = fileno (gf_log_logfile); +        fd = fileno (ctx->log.gf_log_logfile);          /* Pending frames, (if any), list them in order */          ret = write (fd, "pending frames:\n", 16); @@ -1818,7 +1819,7 @@ out:  char *  uuid_utoa (uuid_t uuid)  { -        char *uuid_buffer = glusterfs_uuid_buf_get(); +        char *uuid_buffer = glusterfs_uuid_buf_get(THIS->ctx);          uuid_unparse (uuid, uuid_buffer);          return uuid_buffer;  } @@ -1837,7 +1838,7 @@ uuid_utoa_r (uuid_t uuid, char *dst)  char *  lkowner_utoa (gf_lkowner_t *lkowner)  { -        char *lkowner_buffer = glusterfs_lkowner_buf_get(); +        char *lkowner_buffer = glusterfs_lkowner_buf_get(THIS->ctx);          lkowner_unparse (lkowner, lkowner_buffer, GF_LKOWNER_BUF_SIZE);          return lkowner_buffer;  }  | 
